Decompiled source of SpiderBone v1.0.0

Mods/Spiderman.dll

Decompiled 4 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BoneLib;
using BoneLib.BoneMenu;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.Interaction;
using Il2CppSLZ.Marrow.Utilities;
using Il2CppSLZ.Marrow.Warehouse;
using Il2CppSLZ.VRMK;
using Il2CppSystem;
using LabFusion.Data.Serializables;
using LabFusion.Entities;
using LabFusion.Network;
using LabFusion.Network.Serialization;
using LabFusion.Player;
using LabFusion.SDK.Modules;
using LabFusion.Utilities;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using Spiderman;
using Spiderman.Module;
using Spiderman.Utilities;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(SpidermanMainClass), "Spiderman", "1.0.0", "notnotnotswipez", null)]
[assembly: MelonOptionalDependencies(new string[] { "LabFusion" })]
[assembly: AssemblyTitle("Spiderman")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Spiderman")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("cdde6516-f286-4f2c-ad4b-d75164eb3e75")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace Spiderman
{
	[HarmonyPatch(typeof(WorldGrip), "ValidateGripScore")]
	public class CheckWorldGripTest
	{
		public static void Postfix(WorldGrip __instance, Hand hand, SimpleTransform handTransform, ref ValueTuple<float, float, Vector3, Vector3> __result)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0077: 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_009f: Unknown result type (might be due to invalid IL or missing references)
			if (!SpidermanMainClass.enabled || !SpidermanMainClass.wallClimbing)
			{
				return;
			}
			Vector3 forward = ((SimpleTransform)(ref handTransform)).forward;
			Transform palmPositionTransform = hand.palmPositionTransform;
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(palmPositionTransform.position, palmPositionTransform.forward, ref val, 0.1f, 37953) && !Object.op_Implicit((Object)(object)((RaycastHit)(ref val)).collider.attachedRigidbody))
			{
				float num = Vector3.Dot(-palmPositionTransform.forward, ((RaycastHit)(ref val)).normal);
				if (num > 0.8f)
				{
					__result = new ValueTuple<float, float, Vector3, Vector3>(1.75f, 1f, forward, forward);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Avatar), "RefreshBodyMeasurements", new Type[] { })]
	public class AvatarComputeStats
	{
		public static void Postfix(Avatar __instance)
		{
			if (SpidermanMainClass.enabled && Object.op_Implicit((Object)(object)Player.RigManager) && SpidermanMainClass.increasedStrength)
			{
				RigManager componentInParent = ((Component)__instance).GetComponentInParent<RigManager>();
				if (Object.op_Implicit((Object)(object)componentInParent) && ((Object)componentInParent).GetInstanceID() == ((Object)Player.RigManager).GetInstanceID() && !Object.op_Implicit((Object)(object)((Il2CppObjectBase)__instance).TryCast<RealHeptaAvatar>()))
				{
					__instance._strengthUpper *= 10f;
				}
			}
		}
	}
	public class SixDofManager
	{
		public RigManager targetManager;

		public GameObject activeSeat;

		public static float drag = 25f;

		public SixDofManager(RigManager rigManager)
		{
			targetManager = rigManager;
		}

		public bool IsCurrentlyFreeRotation()
		{
			return (Object)(object)activeSeat != (Object)null;
		}

		public void LockRotation()
		{
			if (Object.op_Implicit((Object)(object)targetManager.activeSeat))
			{
				targetManager.activeSeat.EgressRig(true);
			}
			Object.Destroy((Object)(object)activeSeat);
		}

		public void FreeRotation()
		{
			//IL_0069: 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_00c1: 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_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: 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_0175: Unknown result type (might be due to invalid IL or missing references)
			if (IsCurrentlyFreeRotation())
			{
				if (Object.op_Implicit((Object)(object)targetManager.activeSeat))
				{
					return;
				}
				Object.Destroy((Object)(object)activeSeat);
			}
			activeSeat = Object.Instantiate<GameObject>(SpidermanAssets.sixDOFSeat);
			activeSeat.transform.position = ((Rig)targetManager.physicsRig).m_pelvis.position;
			activeSeat.transform.rotation = ((Rig)targetManager.physicsRig).m_pelvis.rotation;
			Seat component = activeSeat.GetComponent<Seat>();
			((Component)component.footLf).transform.position = ((Rig)targetManager.animationRig).m_footLf.position;
			((Component)component.footRt).transform.position = ((Rig)targetManager.animationRig).m_footRt.position;
			component.blockUnseatAction = true;
			SphereCollider val = ((Component)component.footRt).gameObject.AddComponent<SphereCollider>();
			SphereCollider val2 = ((Component)component.footRt).gameObject.AddComponent<SphereCollider>();
			val2.radius = 0.1f;
			val.radius = 0.1f;
			val2.center += new Vector3(0f, 0.05f, 0f);
			val.center += new Vector3(0f, 0.05f, 0f);
			Rigidbody component2 = activeSeat.GetComponent<Rigidbody>();
			component2.isKinematic = true;
			component2.angularDrag = drag;
			foreach (Collider componentsInChild in activeSeat.GetComponentsInChildren<Collider>())
			{
				componentsInChild.isTrigger = true;
			}
			MelonCoroutines.Start(WaitAndSit(component));
		}

		public IEnumerator WaitAndSit(Seat targetSeat)
		{
			for (int i = 0; i < 5; i++)
			{
				yield return null;
			}
			targetSeat.seatRb.isKinematic = false;
			foreach (Collider collider in ((Component)targetSeat).GetComponentsInChildren<Collider>())
			{
				if (!Object.op_Implicit((Object)(object)((Il2CppObjectBase)collider).TryCast<BoxCollider>()))
				{
					collider.isTrigger = false;
				}
			}
			targetSeat.IngressRig(targetManager);
		}
	}
	public class SpidermanAssets
	{
		public static GameObject sixDOFSeat;

		public static GameObject webLine;

		public static GameObject grip;

		public static GameObject webReticleObject;

		public static AudioClip webShotLow;

		public static AudioClip webShotHigh;

		public static void LoadAssets(AssetBundle bundle)
		{
			sixDOFSeat = bundle.LoadPersistentAsset<GameObject>("assets/spiderman/6dofseat.prefab");
			webLine = bundle.LoadPersistentAsset<GameObject>("assets/spiderman/webline.prefab");
			grip = bundle.LoadPersistentAsset<GameObject>("assets/spiderman/spheregrip.prefab");
			webReticleObject = bundle.LoadPersistentAsset<GameObject>("assets/spiderman/webreticleobject.prefab");
			webShotHigh = bundle.LoadPersistentAsset<AudioClip>("assets/spiderman/webshot_high.ogg");
			webShotLow = bundle.LoadPersistentAsset<AudioClip>("assets/spiderman/webshot_low.ogg");
		}
	}
	[HarmonyPatch(typeof(RigManager), "Awake")]
	public static class RigmanagerAwakePatch
	{
		public static void Postfix(RigManager __instance)
		{
			if (!Object.op_Implicit((Object)(object)SpidermanMainClass.rigManager))
			{
				SpidermanMainClass.sixDofManager = new SixDofManager(__instance);
				SpidermanMainClass.webShootManager = new WebShootManager(__instance, localManager: true);
				SpidermanMainClass.rigManager = __instance;
			}
		}
	}
	public enum InputSetting
	{
		DOUBLE_TRIGGER,
		DOUBLE_GRIP
	}
	public enum WebSetting
	{
		REEL,
		AUTOPULL,
		NONE
	}
	public enum WebHoldSetting
	{
		KEEP_DISTANCE,
		SHORTEN_DISTANCE
	}
	public class SpidermanMainClass : MelonMod
	{
		public static RigManager rigManager;

		public static SixDofManager sixDofManager;

		public static WebShootManager webShootManager;

		public static float pullStrength = 100f;

		public static float maxForce = 1400f;

		public static float zipMultiplier = 1f;

		public static bool auto6Dof = false;

		public static InputSetting inputSetting = InputSetting.DOUBLE_TRIGGER;

		public static WebSetting webSetting = WebSetting.REEL;

		public static WebHoldSetting webHoldSetting = WebHoldSetting.KEEP_DISTANCE;

		public static bool playSounds = true;

		public static bool showWeb = true;

		public static bool increasedStrength = true;

		public static bool showReticle = true;

		public static bool wallClimbing = true;

		public static bool enabled = true;

		private static MelonPreferences_Category mainCategory = MelonPreferences.CreateCategory("SpidermanModSwipez");

		private static MelonPreferences_Entry<InputSetting> inputSettingPref = mainCategory.CreateEntry<InputSetting>("inputSetting", InputSetting.DOUBLE_TRIGGER, "Input Setting", (string)null, false, false, (ValueValidator)null, (string)null);

		private static MelonPreferences_Entry<WebSetting> webSettingPref = mainCategory.CreateEntry<WebSetting>("webSetting", WebSetting.REEL, "Web Setting", (string)null, false, false, (ValueValidator)null, (string)null);

		private static MelonPreferences_Entry<WebHoldSetting> webHoldPref = mainCategory.CreateEntry<WebHoldSetting>("webHoldSetting", WebHoldSetting.KEEP_DISTANCE, "Web Hold Setting", (string)null, false, false, (ValueValidator)null, (string)null);

		private static MelonPreferences_Entry<bool> sixDofBindPref = mainCategory.CreateEntry<bool>("SixDofBind", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);

		private static MelonPreferences_Entry<bool> playSoundsPref = mainCategory.CreateEntry<bool>("playSounds", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);

		private static MelonPreferences_Entry<bool> showWebPref = mainCategory.CreateEntry<bool>("showWeb", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);

		private static MelonPreferences_Entry<bool> increasedStrengthPref = mainCategory.CreateEntry<bool>("increasedStrength", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);

		private static MelonPreferences_Entry<bool> showReticlePref = mainCategory.CreateEntry<bool>("showReticle", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);

		private static MelonPreferences_Entry<bool> enabledPref = mainCategory.CreateEntry<bool>("enabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);

		private static MelonPreferences_Entry<bool> wallClimbingPref = mainCategory.CreateEntry<bool>("wallClimbing", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);

		public override void OnInitializeMelon()
		{
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: 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_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: 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_0310: Unknown result type (might be due to invalid IL or missing references)
			enabled = enabledPref.Value;
			inputSetting = inputSettingPref.Value;
			webSetting = webSettingPref.Value;
			webHoldSetting = webHoldPref.Value;
			WebShootManager.sixDofBind = sixDofBindPref.Value;
			playSounds = playSoundsPref.Value;
			showWeb = showWebPref.Value;
			increasedStrength = increasedStrengthPref.Value;
			showReticle = showReticlePref.Value;
			wallClimbing = wallClimbingPref.Value;
			AssetBundle bundle = ((!HelperMethods.IsAndroid()) ? BundleUtilities.LoadBundleFromInternalAssembly("spiderman.assets") : BundleUtilities.LoadBundleFromInternalAssembly("spiderman.android.assets"));
			SpidermanAssets.LoadAssets(bundle);
			Page val = Page.Root.CreatePage("Spiderman", Color.red, 0, true);
			val.CreateBool("Enabled", Color.green, enabled, (Action<bool>)delegate(bool b)
			{
				enabledPref.Value = b;
				enabled = b;
				mainCategory.SaveToFile(false);
				Player.RigManager.SwapAvatarCrate(((ScannableReference)Player.RigManager.AvatarCrate).Barcode, false, (Action<bool>)null);
			});
			val.CreateEnum("Input Setting", Color.yellow, (Enum)inputSetting, (Action<Enum>)delegate(Enum inputSetting)
			{
				SpidermanMainClass.inputSetting = (InputSetting)(object)inputSetting;
				inputSettingPref.Value = (InputSetting)(object)inputSetting;
				mainCategory.SaveToFile(false);
			});
			val.CreateEnum("Web Setting", Color.yellow, (Enum)webSetting, (Action<Enum>)delegate(Enum webSetting)
			{
				SpidermanMainClass.webSetting = (WebSetting)(object)webSetting;
				webSettingPref.Value = (WebSetting)(object)webSetting;
				mainCategory.SaveToFile(false);
			});
			val.CreateEnum("Web Hold Setting", Color.yellow, (Enum)webHoldSetting, (Action<Enum>)delegate(Enum webHoldSetting)
			{
				SpidermanMainClass.webHoldSetting = (WebHoldSetting)(object)webHoldSetting;
				webHoldPref.Value = (WebHoldSetting)(object)webHoldSetting;
				mainCategory.SaveToFile(false);
			});
			val.CreateFloat("Zip Multiplier", Color.yellow, zipMultiplier, 0.1f, 0f, 100f, (Action<float>)delegate(float zipMult)
			{
				zipMultiplier = zipMult;
			});
			val.CreateBool("Six Dof Bind", Color.yellow, WebShootManager.sixDofBind, (Action<bool>)delegate(bool b)
			{
				WebShootManager.sixDofBind = b;
				sixDofBindPref.Value = b;
				mainCategory.SaveToFile(false);
			});
			val.CreateBool("Play Sounds", Color.green, playSounds, (Action<bool>)delegate(bool b)
			{
				playSounds = b;
				playSoundsPref.Value = b;
				mainCategory.SaveToFile(false);
			});
			val.CreateBool("Show Web", Color.green, showWeb, (Action<bool>)delegate(bool b)
			{
				showWeb = b;
				showWebPref.Value = b;
				mainCategory.SaveToFile(false);
			});
			val.CreateBool("Increased Strength", Color.green, increasedStrength, (Action<bool>)delegate(bool b)
			{
				increasedStrength = b;
				increasedStrengthPref.Value = b;
				mainCategory.SaveToFile(false);
				Player.RigManager.SwapAvatarCrate(((ScannableReference)Player.RigManager.AvatarCrate).Barcode, false, (Action<bool>)null);
			});
			val.CreateBool("Wall Climbing", Color.green, wallClimbing, (Action<bool>)delegate(bool b)
			{
				wallClimbing = b;
				wallClimbingPref.Value = b;
				mainCategory.SaveToFile(false);
			});
			val.CreateBool("Show Reticle", Color.green, showReticle, (Action<bool>)delegate(bool b)
			{
				showReticle = b;
				showReticlePref.Value = b;
				mainCategory.SaveToFile(false);
			});
			if (MelonBase.FindMelon("LabFusion", "Lakatrazz") != null)
			{
				LoadModule();
			}
		}

		private static void LoadModule()
		{
			ModuleManager.RegisterModule<SpidermanModule>();
		}

		public override void OnUpdate()
		{
			webShootManager?.Update();
		}
	}
	public class WebShootManager
	{
		public static Action<Vector3, Rigidbody, float, Handedness> onLocalWebAttached;

		public static Action<Handedness> onLocalWebDetached;

		public static Action<Handedness, float> onLocalWebDistanceChanged;

		public static Action<Rigidbody, Vector3> onLocalZippedRigidbody;

		public RigManager rigManager;

		public WebShooter leftShooter;

		public WebShooter rightShooter;

		public BaseController rightController;

		private bool debounce = false;

		public static bool sixDofBind = true;

		private bool localManager = true;

		public List<int> selfColliders = new List<int>();

		public bool playSounds = true;

		public bool showWeb = true;

		public WebShootManager(RigManager manager, bool localManager)
		{
			rigManager = manager;
			this.localManager = localManager;
			OpenControllerRig val = ((Il2CppObjectBase)rigManager.controllerRig).TryCast<OpenControllerRig>();
			leftShooter = new WebShooter(rigManager.physicsRig.leftHand, val, localManager);
			rightShooter = new WebShooter(rigManager.physicsRig.rightHand, val, localManager);
			leftShooter.otherShooter = rightShooter;
			rightShooter.otherShooter = leftShooter;
			leftShooter.webShootManager = this;
			rightShooter.webShootManager = this;
			rightController = ((ControllerRig)val).rightController;
			foreach (Collider componentsInChild in ((Component)manager).GetComponentsInChildren<Collider>())
			{
				selfColliders.Add(((Object)componentsInChild).GetInstanceID());
			}
		}

		public WebShooter GetWebShooter(Handedness handedness)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			if ((int)handedness == 1)
			{
				return leftShooter;
			}
			return rightShooter;
		}

		public void Update()
		{
			//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)
			if (!Object.op_Implicit((Object)(object)rigManager))
			{
				return;
			}
			leftShooter.Update();
			rightShooter.Update();
			if (!localManager)
			{
				return;
			}
			if (!debounce)
			{
				if (rightController.GetThumbStickDown())
				{
					debounce = true;
					if (sixDofBind)
					{
						if (!SpidermanMainClass.sixDofManager.IsCurrentlyFreeRotation())
						{
							SpidermanMainClass.sixDofManager.FreeRotation();
						}
						else
						{
							SpidermanMainClass.sixDofManager.LockRotation();
						}
					}
				}
			}
			else if (!rightController.GetThumbStickDown())
			{
				debounce = false;
			}
			RaycastHit val = default(RaycastHit);
			if (SpidermanMainClass.auto6Dof && Physics.Raycast(((Component)((Rig)rigManager.physicsRig).m_pelvis).transform.position, Vector3.down, ref val, rigManager.avatar.legLowerLength, 37953) && !leftShooter.shot && !rightShooter.shot && SpidermanMainClass.sixDofManager.IsCurrentlyFreeRotation())
			{
				SpidermanMainClass.sixDofManager.LockRotation();
			}
		}
	}
	public class WebShooter
	{
		public Hand targetHand;

		public ConfigurableJoint joint;

		public GameObject webLineRenderer;

		public GameObject webReticleObject;

		public LineRenderer lineRenderer;

		public OpenControllerRig controllerRig;

		public Vector3 lastLocalPosition;

		private RigManager rigManager;

		public bool shot = false;

		public BaseController targetController;

		private float lastGestureTime = 0f;

		private float gestureWindow = 0.3f;

		private bool gestureDebounce = false;

		private int gesturePressedCount = 0;

		public WebShooter otherShooter;

		public AudioSource audioSource;

		private RaycastHit nearestHit;

		private bool validHit;

		private bool localManager = true;

		private Transform head;

		private float distance = 99f;

		public WebShootManager webShootManager;

		public WebShooter(Hand hand, OpenControllerRig controllerRig, bool localManager)
		{
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Invalid comparison between Unknown and I4
			targetHand = hand;
			this.localManager = localManager;
			head = ((Rig)((Rig)controllerRig).manager.physicsRig).m_head;
			webLineRenderer = Object.Instantiate<GameObject>(SpidermanAssets.webLine);
			webLineRenderer.SetActive(false);
			webReticleObject = Object.Instantiate<GameObject>(SpidermanAssets.webReticleObject);
			webReticleObject.SetActive(false);
			GameObject val = new GameObject("WebSourceAudio");
			audioSource = val.AddComponent<AudioSource>();
			audioSource.spatialBlend = 1f;
			audioSource.volume = 1f;
			audioSource.loop = false;
			val.transform.parent = ((Component)targetHand).transform;
			val.transform.localPosition = Vector3.zero;
			val.transform.localRotation = Quaternion.identity;
			lineRenderer = webLineRenderer.GetComponent<LineRenderer>();
			this.controllerRig = controllerRig;
			if ((int)hand.handedness == 1)
			{
				targetController = ((ControllerRig)controllerRig).leftController;
			}
			else
			{
				targetController = ((ControllerRig)controllerRig).rightController;
			}
			rigManager = ((Rig)controllerRig).manager;
		}

		public void Shoot()
		{
			//IL_0046: 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_009c: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			if (CanShootWeb() && validHit)
			{
				Rigidbody attachedRigidbody = ((RaycastHit)(ref nearestHit)).collider.attachedRigidbody;
				float arg = ((RaycastHit)(ref nearestHit)).distance;
				AttachToPoint(((RaycastHit)(ref nearestHit)).point, attachedRigidbody, arg);
				if (SpidermanMainClass.playSounds)
				{
					PlaySound();
				}
				GameObject obj = webLineRenderer;
				if (obj != null)
				{
					obj.SetActive(SpidermanMainClass.showWeb);
				}
				WebShootManager.onLocalWebAttached?.Invoke(((Joint)joint).connectedAnchor, attachedRigidbody, arg, targetHand.handedness);
				if (SpidermanMainClass.auto6Dof && ((RaycastHit)(ref nearestHit)).point.y > ((Component)targetHand).transform.position.y && (!Object.op_Implicit((Object)(object)((Joint)joint).connectedBody) || ((Joint)joint).connectedBody.mass > ((Rig)controllerRig).manager.avatar._massTotal))
				{
					SpidermanMainClass.sixDofManager.FreeRotation();
				}
			}
		}

		public void AttachToPoint(Vector3 point, Rigidbody body, float distance)
		{
			//IL_0076: 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)
			if (Object.op_Implicit((Object)(object)joint))
			{
				Object.Destroy((Object)(object)joint);
			}
			joint = ((Component)targetHand).gameObject.AddComponent<ConfigurableJoint>();
			joint.SetLinearDrive(5000f, 100f);
			joint.SetLinearLimit(distance);
			if (Object.op_Implicit((Object)(object)body))
			{
				((Joint)joint).connectedBody = body;
			}
			joint.SetConnectedPoint(point);
			joint.SetMotion((ConfigurableJointMotion)1);
			joint.SetRotation((ConfigurableJointMotion)2);
			((Joint)joint).anchor = Vector3.zero;
			this.distance = distance;
			shot = true;
		}

		public void PlaySound()
		{
			AudioClip val = SpidermanAssets.webShotHigh;
			if (Random.Range(0f, 1f) < 0.5f)
			{
				val = SpidermanAssets.webShotLow;
			}
			float pitch = Random.Range(0.8f, 1.2f);
			audioSource.pitch = pitch;
			audioSource.PlayOneShot(val);
		}

		public void CheckZip()
		{
			//IL_0002: 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_001c: 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)
			//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_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: 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_019b: 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_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: 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_0162: 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_0173: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = lastLocalPosition - ((Component)targetController).transform.localPosition;
			val /= Time.deltaTime;
			if ((double)((Vector3)(ref val)).magnitude > 1.5 && shot)
			{
				Vector3 val2 = ((Component)targetHand).transform.position - joint.GetConnectedPoint();
				Vector3 val3 = ((Vector3)(ref val2)).normalized * ((Vector3)(ref val)).magnitude * SpidermanMainClass.zipMultiplier;
				bool flag = false;
				Avatar avatar = rigManager.avatar;
				if (Object.op_Implicit((Object)(object)((Joint)joint).connectedBody) && !((Joint)joint).connectedBody.isKinematic && ((Joint)joint).connectedBody.mass < avatar._massTotal)
				{
					flag = true;
				}
				float num = avatar._height / 1.7f;
				if (!flag)
				{
					Rigidbody component = ((Component)((Rig)rigManager.physicsRig).m_pelvis).GetComponent<Rigidbody>();
					component.AddForce(val3 * -1f * 20f * num, (ForceMode)1);
					WebShootManager.onLocalZippedRigidbody?.Invoke(component, val3 * -1f * 20f * num);
				}
				else
				{
					((Joint)joint).connectedBody.AddForce(val3 * 2f * num, (ForceMode)1);
					WebShootManager.onLocalZippedRigidbody?.Invoke(((Joint)joint).connectedBody, val3 * 2f * num);
				}
			}
			lastLocalPosition = ((Component)targetController).transform.localPosition;
		}

		public void UpdateReticle()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			bool flag = true;
			if (!SpidermanMainClass.showReticle || IsWebShot() || !CanShootWeb())
			{
				flag = false;
			}
			webReticleObject.SetActive(flag);
			if (flag)
			{
				if (validHit)
				{
					Transform transform = webReticleObject.transform;
					transform.position = ((RaycastHit)(ref nearestHit)).point + ((RaycastHit)(ref nearestHit)).normal * 0.01f;
					transform.LookAt(((RaycastHit)(ref nearestHit)).point + ((RaycastHit)(ref nearestHit)).normal, Vector3.up);
				}
				else
				{
					webReticleObject.SetActive(false);
				}
			}
		}

		private bool LinearCast(Vector3 origin, Vector3 direction, out RaycastHit hit, float distance, int layerMask)
		{
			//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_000f: 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_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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0084: 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)
			Il2CppStructArray<RaycastHit> val = Physics.RaycastAll(origin, direction, distance, layerMask);
			RaycastHit val2 = default(RaycastHit);
			((RaycastHit)(ref val2)).point = Vector3.positiveInfinity;
			((RaycastHit)(ref val2)).distance = float.PositiveInfinity;
			RaycastHit val3 = val2;
			bool result = false;
			foreach (RaycastHit item in (Il2CppArrayBase<RaycastHit>)(object)val)
			{
				RaycastHit current = item;
				if (!webShootManager.selfColliders.Contains(((Object)((RaycastHit)(ref current)).collider).GetInstanceID()) && ((RaycastHit)(ref val3)).distance > ((RaycastHit)(ref current)).distance)
				{
					val3 = current;
					result = true;
				}
			}
			hit = val3;
			return result;
		}

		public void Update()
		{
			//IL_001e: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			if (IsWebShot())
			{
				lineRenderer.SetPosition(0, ((Component)targetHand).transform.position);
				lineRenderer.SetPosition(1, joint.GetConnectedPoint());
			}
			if (!localManager)
			{
				return;
			}
			if (LinearCast(((Component)targetHand).transform.position, ((Component)targetHand).transform.forward, out var hit, 300f, 38209))
			{
				validHit = true;
				nearestHit = hit;
			}
			else
			{
				validHit = false;
			}
			UpdateReticle();
			CheckGestureInput();
			CheckZip();
			if (!IsWebShot())
			{
				return;
			}
			float num = targetController._thumbstickAxis.y;
			if (SpidermanMainClass.webSetting == WebSetting.AUTOPULL)
			{
				num = 1f;
			}
			else if (SpidermanMainClass.webSetting == WebSetting.NONE)
			{
				num = 0f;
			}
			float num2 = SpidermanMainClass.pullStrength * num;
			JointExtensions.SetPosDrives(spring: (!Object.op_Implicit((Object)(object)((Joint)joint).connectedBody)) ? (num2 * ((Rig)controllerRig).manager.avatar.massTotal) : (num2 * ((Joint)joint).connectedBody.mass), joint: joint, damp: 1f, maxForce: SpidermanMainClass.maxForce);
			if (SpidermanMainClass.webHoldSetting == WebHoldSetting.SHORTEN_DISTANCE)
			{
				float num3 = Vector3.Distance(joint.GetConnectedPoint(), ((Component)targetHand).transform.position);
				if (num3 < distance)
				{
					distance = num3;
					joint.SetLinearLimit(num3);
					WebShootManager.onLocalWebDistanceChanged?.Invoke(targetHand.handedness, num3);
				}
			}
			if (!IsDoingPose())
			{
				Release();
				WebShootManager.onLocalWebDetached?.Invoke(targetHand.handedness);
			}
		}

		private void CheckGestureInput()
		{
			if (SpidermanMainClass.inputSetting == InputSetting.DOUBLE_TRIGGER)
			{
				if (!targetController.isBelowGripThreshold)
				{
					return;
				}
				if (!gestureDebounce)
				{
					if (targetController._primaryAxis >= 0.85f)
					{
						UpdateGesture();
					}
				}
				else if (targetController._primaryAxis <= 0.5f)
				{
					gestureDebounce = false;
				}
			}
			else
			{
				if (SpidermanMainClass.inputSetting != InputSetting.DOUBLE_GRIP)
				{
					return;
				}
				if (!gestureDebounce)
				{
					if (targetController.isBelowGripThreshold)
					{
						UpdateGesture();
					}
				}
				else if (!targetController.isBelowGripThreshold)
				{
					gestureDebounce = false;
				}
			}
		}

		private bool IsWebShot()
		{
			return shot && Object.op_Implicit((Object)(object)joint);
		}

		private bool CanShootWeb()
		{
			return !targetHand.HasAttachedObject() && SpidermanMainClass.enabled;
		}

		private void UpdateGesture()
		{
			if (Time.time - lastGestureTime <= gestureWindow)
			{
				gesturePressedCount++;
				if (gesturePressedCount >= 1)
				{
					Shoot();
				}
			}
			else
			{
				gesturePressedCount = 0;
			}
			lastGestureTime = Time.time;
			gestureDebounce = true;
		}

		public void Release()
		{
			if (Object.op_Implicit((Object)(object)joint))
			{
				Object.Destroy((Object)(object)joint);
			}
			webLineRenderer.SetActive(false);
			shot = false;
		}

		private bool IsDoingPose()
		{
			if (SpidermanMainClass.inputSetting == InputSetting.DOUBLE_TRIGGER)
			{
				if (targetController.isBelowGripThreshold && targetController._primaryAxis >= 0.85f)
				{
					return true;
				}
			}
			else if (SpidermanMainClass.inputSetting == InputSetting.DOUBLE_GRIP && targetController.isBelowGripThreshold)
			{
				return true;
			}
			return false;
		}
	}
}
namespace Spiderman.Utilities
{
	public class BundleUtilities
	{
		public static byte[] GetResourceBytes(string filename)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
			foreach (string text in manifestResourceNames)
			{
				if (!text.Contains(filename))
				{
					continue;
				}
				using Stream stream = executingAssembly.GetManifestResourceStream(text);
				if (stream == null)
				{
					return null;
				}
				byte[] array = new byte[stream.Length];
				stream.Read(array, 0, array.Length);
				return array;
			}
			return null;
		}

		public static AssetBundle LoadBundleFromInternalAssembly(string filename)
		{
			return AssetBundle.LoadFromMemory(Il2CppStructArray<byte>.op_Implicit(GetResourceBytes(filename)));
		}
	}
	public static class AssetBundleExtension
	{
		public static T LoadPersistentAsset<T>(this AssetBundle bundle, string name) where T : Object
		{
			Object val = bundle.LoadAsset(name);
			if (val != (Object)null)
			{
				val.hideFlags = (HideFlags)32;
				return ((Il2CppObjectBase)val).TryCast<T>();
			}
			return default(T);
		}
	}
	public static class JointExtensions
	{
		public static void SetLinearDrive(this ConfigurableJoint joint, float drive, float damp)
		{
			//IL_0004: 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)
			SoftJointLimitSpring linearLimitSpring = default(SoftJointLimitSpring);
			((SoftJointLimitSpring)(ref linearLimitSpring)).spring = drive;
			((SoftJointLimitSpring)(ref linearLimitSpring)).damper = damp;
			joint.linearLimitSpring = linearLimitSpring;
		}

		public static void SetConnectedPoint(this ConfigurableJoint joint, Vector3 pos)
		{
			//IL_0036: 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)
			((Joint)joint).autoConfigureConnectedAnchor = false;
			if (Object.op_Implicit((Object)(object)((Joint)joint).connectedBody))
			{
				((Joint)joint).connectedAnchor = ((Component)((Joint)joint).connectedBody).transform.InverseTransformPoint(pos);
			}
			else
			{
				((Joint)joint).connectedAnchor = pos;
			}
		}

		public static Vector3 GetConnectedPoint(this ConfigurableJoint joint)
		{
			//IL_002b: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)((Joint)joint).connectedBody))
			{
				return ((Component)((Joint)joint).connectedBody).transform.TransformPoint(((Joint)joint).connectedAnchor);
			}
			return ((Joint)joint).connectedAnchor;
		}

		public static void SetLinearLimit(this ConfigurableJoint joint, float distance)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			SoftJointLimit linearLimit = default(SoftJointLimit);
			((SoftJointLimit)(ref linearLimit)).limit = distance;
			joint.linearLimit = linearLimit;
		}

		public static void SetMotion(this ConfigurableJoint joint, ConfigurableJointMotion motion)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			joint.xMotion = motion;
			joint.yMotion = motion;
			joint.zMotion = motion;
		}

		public static void SetRotation(this ConfigurableJoint joint, ConfigurableJointMotion motion)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			joint.angularXMotion = motion;
			joint.angularYMotion = motion;
			joint.angularZMotion = motion;
		}

		public static void SetRotDrives(this ConfigurableJoint joint, float spring, float damp)
		{
			//IL_0004: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			JointDrive angularXDrive = default(JointDrive);
			((JointDrive)(ref angularXDrive)).positionSpring = spring;
			((JointDrive)(ref angularXDrive)).positionDamper = damp;
			((JointDrive)(ref angularXDrive)).maximumForce = float.PositiveInfinity;
			joint.angularXDrive = angularXDrive;
			joint.angularYZDrive = joint.angularXDrive;
		}

		public static void SetPosDrives(this ConfigurableJoint joint, float spring, float damp, float maxForce)
		{
			//IL_0004: 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_002e: 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)
			JointDrive xDrive = default(JointDrive);
			((JointDrive)(ref xDrive)).positionSpring = spring;
			((JointDrive)(ref xDrive)).positionDamper = damp;
			((JointDrive)(ref xDrive)).maximumForce = maxForce;
			joint.xDrive = xDrive;
			joint.yDrive = joint.xDrive;
			joint.zDrive = joint.xDrive;
		}
	}
}
namespace Spiderman.Module
{
	public class SpidermanModule : Module
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Action<NetworkPlayer, RigManager> <>9__9_0;

			public static PlayerUpdate <>9__9_1;

			public static ServerEvent <>9__9_2;

			public static UpdateEvent <>9__9_3;

			public static Action<Vector3, Rigidbody, float, Handedness> <>9__9_4;

			public static Action<Handedness> <>9__9_5;

			public static Action<Handedness, float> <>9__9_6;

			internal void <OnModuleRegistered>b__9_0(NetworkPlayer netPlayer, RigManager rigManager)
			{
				if (!netPlayer.PlayerID.IsMe)
				{
					if (repShootManagers.ContainsKey(netPlayer.PlayerID.SmallID))
					{
						repShootManagers[netPlayer.PlayerID.SmallID] = new WebShootManager(rigManager, localManager: false);
					}
					else
					{
						repShootManagers.Add(netPlayer.PlayerID.SmallID, new WebShootManager(rigManager, localManager: false));
					}
				}
			}

			internal void <OnModuleRegistered>b__9_1(PlayerID id)
			{
				repShootManagers.Remove(id.SmallID);
			}

			internal void <OnModuleRegistered>b__9_2()
			{
				repShootManagers.Clear();
			}

			internal void <OnModuleRegistered>b__9_3()
			{
				foreach (KeyValuePair<byte, WebShootManager> repShootManager in repShootManagers)
				{
					repShootManager.Value.Update();
				}
			}

			internal void <OnModuleRegistered>b__9_4(Vector3 pos, Rigidbody body, float distance, Handedness handedness)
			{
				//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_0052: 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_0065: Expected O, but got Unknown
				//IL_007d: Unknown result type (might be due to invalid IL or missing references)
				if (NetworkInfo.HasServer)
				{
					GameObject val = null;
					if (Object.op_Implicit((Object)(object)body))
					{
						val = ((Component)body).gameObject;
						ImpactUtilities.OnHitRigidbody(body);
					}
					WebshooterStateData webshooterStateData = new WebshooterStateData
					{
						playerId = PlayerID.op_Implicit(PlayerIDManager.LocalID),
						point = pos,
						attach = true,
						distance = distance,
						handedness = handedness,
						attachedBody = new GameObjectReference(val),
						playSound = SpidermanMainClass.playSounds,
						showWeb = SpidermanMainClass.showWeb
					};
					MessageRelay.RelayModule<WebshooterStateMessage, WebshooterStateData>(webshooterStateData, CommonMessageRoutes.ReliableToOtherClients);
				}
			}

			internal void <OnModuleRegistered>b__9_5(Handedness handedness)
			{
				//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_003e: 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_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Expected O, but got Unknown
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				if (NetworkInfo.HasServer)
				{
					WebshooterStateData webshooterStateData = new WebshooterStateData
					{
						playerId = PlayerID.op_Implicit(PlayerIDManager.LocalID),
						point = Vector3.zero,
						attach = false,
						distance = 1f,
						handedness = handedness,
						attachedBody = new GameObjectReference((GameObject)null)
					};
					MessageRelay.RelayModule<WebshooterStateMessage, WebshooterStateData>(webshooterStateData, CommonMessageRoutes.ReliableToOtherClients);
				}
			}

			internal void <OnModuleRegistered>b__9_6(Handedness handedness, float distance)
			{
				//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_0030: Unknown result type (might be due to invalid IL or missing references)
				if (NetworkInfo.HasServer)
				{
					WebshooterUpdateData webshooterUpdateData = new WebshooterUpdateData
					{
						playerId = PlayerID.op_Implicit(PlayerIDManager.LocalID),
						distance = distance,
						handedness = handedness
					};
					MessageRelay.RelayModule<WebshooterUpdateMessage, WebshooterUpdateData>(webshooterUpdateData, CommonMessageRoutes.UnreliableToOtherClients);
				}
			}
		}

		public static Dictionary<byte, WebShootManager> repShootManagers = new Dictionary<byte, WebShootManager>();

		public override string Name => "SpidermanModule";

		public override string Author => "notnotnotswipez";

		public override Version Version => new Version("1.0.0");

		public override ConsoleColor Color => ConsoleColor.Red;

		protected override void OnModuleRegistered()
		{
			//IL_0046: 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_0051: Expected O, but got Unknown
			//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_0076: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			ModuleMessageManager.RegisterHandler<WebshooterStateMessage>();
			ModuleMessageManager.RegisterHandler<WebshooterUpdateMessage>();
			NetworkPlayer.OnNetworkRigCreated += delegate(NetworkPlayer netPlayer, RigManager rigManager)
			{
				if (!netPlayer.PlayerID.IsMe)
				{
					if (repShootManagers.ContainsKey(netPlayer.PlayerID.SmallID))
					{
						repShootManagers[netPlayer.PlayerID.SmallID] = new WebShootManager(rigManager, localManager: false);
					}
					else
					{
						repShootManagers.Add(netPlayer.PlayerID.SmallID, new WebShootManager(rigManager, localManager: false));
					}
				}
			};
			object obj = <>c.<>9__9_1;
			if (obj == null)
			{
				PlayerUpdate val = delegate(PlayerID id)
				{
					repShootManagers.Remove(id.SmallID);
				};
				<>c.<>9__9_1 = val;
				obj = (object)val;
			}
			MultiplayerHooking.OnPlayerLeft += (PlayerUpdate)obj;
			object obj2 = <>c.<>9__9_2;
			if (obj2 == null)
			{
				ServerEvent val2 = delegate
				{
					repShootManagers.Clear();
				};
				<>c.<>9__9_2 = val2;
				obj2 = (object)val2;
			}
			MultiplayerHooking.OnDisconnected += (ServerEvent)obj2;
			object obj3 = <>c.<>9__9_3;
			if (obj3 == null)
			{
				UpdateEvent val3 = delegate
				{
					foreach (KeyValuePair<byte, WebShootManager> repShootManager in repShootManagers)
					{
						repShootManager.Value.Update();
					}
				};
				<>c.<>9__9_3 = val3;
				obj3 = (object)val3;
			}
			MultiplayerHooking.OnUpdate += (UpdateEvent)obj3;
			WebShootManager.onLocalWebAttached = (Action<Vector3, Rigidbody, float, Handedness>)Delegate.Combine(WebShootManager.onLocalWebAttached, (Action<Vector3, Rigidbody, float, Handedness>)delegate(Vector3 pos, Rigidbody body, float distance, Handedness handedness)
			{
				//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_0052: 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_0065: Expected O, but got Unknown
				//IL_007d: Unknown result type (might be due to invalid IL or missing references)
				if (NetworkInfo.HasServer)
				{
					GameObject val4 = null;
					if (Object.op_Implicit((Object)(object)body))
					{
						val4 = ((Component)body).gameObject;
						ImpactUtilities.OnHitRigidbody(body);
					}
					WebshooterStateData webshooterStateData2 = new WebshooterStateData
					{
						playerId = PlayerID.op_Implicit(PlayerIDManager.LocalID),
						point = pos,
						attach = true,
						distance = distance,
						handedness = handedness,
						attachedBody = new GameObjectReference(val4),
						playSound = SpidermanMainClass.playSounds,
						showWeb = SpidermanMainClass.showWeb
					};
					MessageRelay.RelayModule<WebshooterStateMessage, WebshooterStateData>(webshooterStateData2, CommonMessageRoutes.ReliableToOtherClients);
				}
			});
			WebShootManager.onLocalWebDetached = (Action<Handedness>)Delegate.Combine(WebShootManager.onLocalWebDetached, (Action<Handedness>)delegate(Handedness handedness)
			{
				//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_003e: 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_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Expected O, but got Unknown
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				if (NetworkInfo.HasServer)
				{
					WebshooterStateData webshooterStateData = new WebshooterStateData
					{
						playerId = PlayerID.op_Implicit(PlayerIDManager.LocalID),
						point = Vector3.zero,
						attach = false,
						distance = 1f,
						handedness = handedness,
						attachedBody = new GameObjectReference((GameObject)null)
					};
					MessageRelay.RelayModule<WebshooterStateMessage, WebshooterStateData>(webshooterStateData, CommonMessageRoutes.ReliableToOtherClients);
				}
			});
			WebShootManager.onLocalWebDistanceChanged = (Action<Handedness, float>)Delegate.Combine(WebShootManager.onLocalWebDistanceChanged, (Action<Handedness, float>)delegate(Handedness handedness, float distance)
			{
				//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_0030: Unknown result type (might be due to invalid IL or missing references)
				if (NetworkInfo.HasServer)
				{
					WebshooterUpdateData webshooterUpdateData = new WebshooterUpdateData
					{
						playerId = PlayerID.op_Implicit(PlayerIDManager.LocalID),
						distance = distance,
						handedness = handedness
					};
					MessageRelay.RelayModule<WebshooterUpdateMessage, WebshooterUpdateData>(webshooterUpdateData, CommonMessageRoutes.UnreliableToOtherClients);
				}
			});
		}

		protected override void OnModuleUnregistered()
		{
		}
	}
	public class WebshooterStateData : INetSerializable
	{
		public byte playerId;

		public bool attach;

		public Handedness handedness;

		public GameObjectReference attachedBody;

		public Vector3 point;

		public float distance;

		public bool playSound = true;

		public bool showWeb = true;

		public int? GetSize()
		{
			return 3 + attachedBody.GetSize() + 12 + 4 + 1 + 1;
		}

		public void Serialize(INetSerializer serializer)
		{
			serializer.SerializeValue(ref playerId);
			serializer.SerializeValue(ref attach);
			serializer.SerializeValue<Handedness>(ref handedness);
			NetSerializerExtensions.SerializeValue<GameObjectReference>(serializer, ref attachedBody);
			NetSerializerUnityExtensions.SerializeValue(serializer, ref point);
			serializer.SerializeValue(ref distance);
			serializer.SerializeValue(ref playSound);
			serializer.SerializeValue(ref showWeb);
		}
	}
	public class WebshooterStateMessage : ModuleMessageHandler
	{
		protected override void OnHandleMessage(ReceivedMessage received)
		{
			//IL_0066: 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: Invalid comparison between Unknown and I4
			WebshooterStateData data = ((ReceivedMessage)(ref received)).ReadData<WebshooterStateData>();
			if (!SpidermanModule.repShootManagers.ContainsKey(data.playerId))
			{
				return;
			}
			WebShootManager webShootManager = SpidermanModule.repShootManagers[data.playerId];
			WebShooter targetWebShooter = webShootManager.GetWebShooter(data.handedness);
			if (data.attach)
			{
				if ((int)data.attachedBody.Type > 0)
				{
					data.attachedBody.HookGameObjectFound((Action<GameObject>)OnAttachTargetFound);
				}
				else
				{
					OnAttachTargetFound(null);
				}
			}
			else
			{
				targetWebShooter.Release();
			}
			void OnAttachTargetFound(GameObject obj)
			{
				//IL_0027: 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)
				Rigidbody val = null;
				if (Object.op_Implicit((Object)(object)obj))
				{
					val = obj.GetComponent<Rigidbody>();
				}
				targetWebShooter.AttachToPoint(data.point, val, data.distance);
				if (Object.op_Implicit((Object)(object)val))
				{
					((Joint)targetWebShooter.joint).connectedAnchor = data.point;
				}
				if (data.playSound)
				{
					targetWebShooter.PlaySound();
				}
				targetWebShooter.webLineRenderer.SetActive(data.showWeb);
			}
		}
	}
	public class WebshooterUpdateData : INetSerializable
	{
		public byte playerId;

		public Handedness handedness;

		public float distance;

		public int? GetSize()
		{
			return 6;
		}

		public void Serialize(INetSerializer serializer)
		{
			serializer.SerializeValue(ref playerId);
			serializer.SerializeValue<Handedness>(ref handedness);
			serializer.SerializeValue(ref distance);
		}
	}
	public class WebshooterUpdateMessage : ModuleMessageHandler
	{
		protected override void OnHandleMessage(ReceivedMessage received)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			WebshooterUpdateData webshooterUpdateData = ((ReceivedMessage)(ref received)).ReadData<WebshooterUpdateData>();
			if (SpidermanModule.repShootManagers.ContainsKey(webshooterUpdateData.playerId))
			{
				WebShootManager webShootManager = SpidermanModule.repShootManagers[webshooterUpdateData.playerId];
				WebShooter webShooter = webShootManager.GetWebShooter(webshooterUpdateData.handedness);
				if (Object.op_Implicit((Object)(object)webShooter.joint))
				{
					webShooter.joint.SetLinearLimit(webshooterUpdateData.distance);
				}
			}
		}
	}
}