Decompiled source of Grappling Hook v1.0.2
plugins/WhiteKnuckleSwingHook/WhiteKnuckleSwingHook.dll
Decompiled 10 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Audio; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("WhiteKnuckleSwingHook")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("WhiteKnuckleSwingHook")] [assembly: AssemblyTitle("WhiteKnuckleSwingHook")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace WhiteKnuckleSwingHook { internal static class CustomItem { [HarmonyPatch(typeof(CL_AssetManager), "InitializeAssetManager")] private static class InitPatch { private static void Postfix() { TryRegister(); } } public const string PrefabName = "Item_SwingGrapple"; public const string DatabaseId = "(USER)_swinghook"; private static bool registered; private static GameObject holder; public static void TryRegister() { if (registered || (Object)(object)CL_AssetManager.baseDatabase == (Object)null) { return; } WKAssetDatabase fullCombinedAssetDatabase; try { fullCombinedAssetDatabase = CL_AssetManager.GetFullCombinedAssetDatabase(); } catch { return; } GameObject val = ((IEnumerable<GameObject>)fullCombinedAssetDatabase.itemPrefabs).FirstOrDefault((Func<GameObject, bool>)((GameObject p) => (Object)(object)p != (Object)null && p.GetComponent<Item_Object>()?.itemData?.handItemAsset is HandItem_GrapplingHook)); if ((Object)(object)val == (Object)null) { SwingHookPlugin.Log.LogError((object)"Couldn't find the game's grappling hook to read hand layout from."); return; } registered = true; try { if (HookAssets.Load()) { Build(val); } } catch (Exception ex) { SwingHookPlugin.Log.LogError((object)("Failed to create the Grappling Hook item: " + ex)); } } private static void Build(GameObject reference) { //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_001d: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0046: Expected O, but got Unknown Item itemData = reference.GetComponent<Item_Object>().itemData; HandItem_GrapplingHook val = (HandItem_GrapplingHook)itemData.handItemAsset; GameRefs.ReadFrom(val); holder = new GameObject("SwingHook_Prefabs"); holder.SetActive(false); Object.DontDestroyOnLoad((Object)(object)holder); HandItem_SwingHook hand = BuildHand(val); Item_Object val2 = BuildWorld(reference, itemData, hand); WKAssetDatabase val3 = ScriptableObject.CreateInstance<WKAssetDatabase>(); ((Object)val3).name = "(USER)_swinghook"; val3.id = "(USER)_swinghook"; val3.itemPrefabs.Add(((Component)val2).gameObject); Object.DontDestroyOnLoad((Object)(object)val3); CL_AssetManager.AddNewDatabase("(USER)_swinghook", val3); SwingHookPlugin.Log.LogInfo((object)("Registered '" + val2.itemData.itemName + "' as Item_SwingGrapple. Spawn it with: spawnitem " + "Item_SwingGrapple".ToLower())); } private static HandItem_SwingHook BuildHand(HandItem_GrapplingHook refHand) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: 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_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017e: 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) Transform transform = ((Component)refHand).transform; GameObject val = new GameObject("HandItem_SwingGrapple"); val.layer = ((Component)transform).gameObject.layer; val.transform.SetParent(holder.transform, false); val.transform.localScale = transform.localScale; ViewSway component = ((Component)refHand).GetComponent<ViewSway>(); ViewSway to = val.AddComponent<ViewSway>(); if ((Object)(object)component != (Object)null) { CopySway(component, to); } SpriteRenderer val2 = ((IEnumerable<SpriteRenderer>)((Component)refHand).GetComponentsInChildren<SpriteRenderer>(true)).FirstOrDefault((Func<SpriteRenderer, bool>)((SpriteRenderer r) => ((Object)r).name == "Item_Hands_Background_Sprite")); GameObject val3 = new GameObject("SwingHook_Sprite"); val3.layer = val.layer; val3.transform.SetParent(val.transform, false); SpriteRenderer val4 = val3.AddComponent<SpriteRenderer>(); val4.sprite = HookAssets.HeldSprite; if ((Object)(object)val2 != (Object)null) { Transform transform2 = ((Component)val2).transform; val3.layer = ((Component)transform2).gameObject.layer; val3.transform.localPosition = transform.InverseTransformPoint(transform2.position); val3.transform.localRotation = Quaternion.Inverse(transform.rotation) * transform2.rotation; Vector3 lossyScale = transform.lossyScale; val3.transform.localScale = new Vector3(transform2.lossyScale.x / lossyScale.x, transform2.lossyScale.y / lossyScale.y, transform2.lossyScale.z / lossyScale.z); ((Renderer)val4).sharedMaterial = ((Renderer)val2).sharedMaterial; ((Renderer)val4).sortingLayerID = ((Renderer)val2).sortingLayerID; ((Renderer)val4).sortingOrder = ((Renderer)val2).sortingOrder; val4.flipX = val2.flipX; } else { SwingHookPlugin.Log.LogWarning((object)"Couldn't read the hand sprite layout; the held sprite may be misplaced."); } HandItem_SwingHook handItem_SwingHook = val.AddComponent<HandItem_SwingHook>(); ((HandItem)handItem_SwingHook).canUseWhileHanging = true; ((HandItem)handItem_SwingHook).useSprintViewSway = ((HandItem)refHand).useSprintViewSway; return handItem_SwingHook; } private static void CopySway(ViewSway from, ViewSway to) { FieldInfo[] fields = typeof(ViewSway).GetFields(BindingFlags.Instance | BindingFlags.Public); foreach (FieldInfo fieldInfo in fields) { if (!(fieldInfo.FieldType == typeof(ViewSwayParameters))) { fieldInfo.SetValue(to, fieldInfo.GetValue(from)); } } to.parameters = CopyParams(from.parameters); } private static ViewSwayParameters CopyParams(ViewSwayParameters p) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown ViewSwayParameters val = new ViewSwayParameters(); if (p == null) { return val; } FieldInfo[] fields = typeof(ViewSwayParameters).GetFields(BindingFlags.Instance | BindingFlags.Public); foreach (FieldInfo obj in fields) { object obj2 = obj.GetValue(p); AnimationCurve val2 = (AnimationCurve)((obj2 is AnimationCurve) ? obj2 : null); if (val2 != null) { obj2 = (object)new AnimationCurve(val2.keys); } obj.SetValue(val, obj2); } return val; } private static Item_Object BuildWorld(GameObject reference, Item refData, HandItem_SwingHook hand) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_003d: 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_004e: 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_0066: 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_0076: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_013c: 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_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Expected O, but got Unknown //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Expected O, but got Unknown //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Expected O, but got Unknown //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Expected O, but got Unknown //IL_01db: 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_01f0: 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_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0284: 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_0295: 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_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Expected O, but got Unknown GameObject val = new GameObject("Item_SwingGrapple"); val.layer = reference.layer; val.transform.SetParent(holder.transform, false); float value = SwingHookPlugin.ModelScale.Value; GameObject val2 = new GameObject("SwingHook_World") { layer = val.layer }; val2.transform.SetParent(val.transform, false); val2.transform.localScale = Vector3.one * value; val2.AddComponent<MeshFilter>().sharedMesh = HookAssets.HookMesh; Renderer val3 = (Renderer)(object)reference.GetComponentsInChildren<MeshRenderer>(true).FirstOrDefault(); ((Renderer)val2.AddComponent<MeshRenderer>()).sharedMaterial = ModelLoader.MakeMaterial(HookAssets.HookTexture, "SwingHook_World", ((Object)(object)val3 != (Object)null) ? val3.sharedMaterial : null); Bounds bounds = HookAssets.HookMesh.bounds; BoxCollider obj = val.AddComponent<BoxCollider>(); obj.center = ((Bounds)(ref bounds)).center * value; obj.size = ((Bounds)(ref bounds)).size * value; Rigidbody val4 = val.AddComponent<Rigidbody>(); Rigidbody component = reference.GetComponent<Rigidbody>(); if ((Object)(object)component != (Object)null) { val4.mass = component.mass; val4.linearDamping = component.linearDamping; val4.angularDamping = component.angularDamping; val4.interpolation = component.interpolation; val4.collisionDetectionMode = component.collisionDetectionMode; } else { val4.mass = 2f; val4.interpolation = (RigidbodyInterpolation)0; } ObjectTagger val5 = val.AddComponent<ObjectTagger>(); val5.tags = new List<string> { "Item" }; val.AddComponent<ItemClickable>(); Item_Object val6 = val.AddComponent<Item_Object>(); val6.tagger = val5; val6.canPickup = true; val6.pickupEvent = new UnityEvent(); val6.onPlaceInInventory = new UnityEvent(); val6.onPlaceInWorld = new UnityEvent(); val6.onDrop = new UnityEvent(); val6.itemData = new Item { itemName = SwingHookPlugin.ItemName.Value, prefabName = "Item_SwingGrapple", itemTag = "", itemTags = new List<string> { "Item", "Tool" }, data = new List<string>(), dataModules = new List<Item_Data>(), dataModuleSaves = new List<DataModuleSave>(), executionModules = new List<ItemExecutionModule>(), pickupSounds = ((refData.pickupSounds != null) ? new List<AudioClip>(refData.pickupSounds) : new List<AudioClip>()), itemAsset = val6, handItemAsset = (HandItem)(object)hand, unlockType = (UnlockType)0, inventoryScale = refData.inventoryScale, lockboxScale = refData.lockboxScale, itemWeight = refData.itemWeight, pocketable = refData.pocketable, pouchable = refData.pouchable, upDirection = refData.upDirection, interactType = refData.interactType, customDropLayer = refData.customDropLayer, worth = refData.worth, allowCosmetics = false }; return val6; } } public class ItemClickable : MonoBehaviour, Clickable { public bool CanInteract(Interaction info) { return true; } public ObjectTagger GetTagger() { return ((Component)this).GetComponent<ObjectTagger>(); } public GameObject GetGameObject() { return ((Component)this).gameObject; } } internal static class GameRefs { private class Sound { public List<AudioClip> clips; public float minVolume; public float maxVolume; public float minPitch; public float maxPitch; public float spatialBlend; } public static LayerMask GrappleMask = LayerMask.op_Implicit(-1); public static float JumpForce = 1f; private static readonly Dictionary<string, Sound> sounds = new Dictionary<string, Sound>(); public static void ReadFrom(HandItem_GrapplingHook barnacle) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) GrappleMask = barnacle.grappleMask; JumpForce = barnacle.grappleJumpForce; UT_AudioClipHandler component = ((Component)barnacle).GetComponent<UT_AudioClipHandler>(); if ((Object)(object)component == (Object)null || component.groups == null) { return; } foreach (AudioGroup group in component.groups) { if (group?.audioSets == null) { continue; } foreach (AudioSet audioSet in group.audioSets) { if (audioSet?.clips != null && audioSet.clips.Count != 0) { sounds[group.name + ":" + audioSet.name] = new Sound { clips = new List<AudioClip>(audioSet.clips), minVolume = audioSet.minVolume, maxVolume = audioSet.maxVolume, minPitch = audioSet.minPitch, maxPitch = audioSet.maxPitch, spatialBlend = audioSet.spatialBlend }; } } } SwingHookPlugin.Log.LogInfo((object)("Borrowed sounds: " + string.Join(", ", sounds.Keys))); } public static void Play(string key, Vector3 position) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (sounds.TryGetValue(key, out var value)) { AudioClip val = value.clips[Random.Range(0, value.clips.Count)]; if (!((Object)(object)val == (Object)null)) { AudioManager.PlaySound(val, position, Random.Range(value.minVolume, value.maxVolume), Random.Range(value.minPitch, value.maxPitch), value.spatialBlend, false, 1f, (AudioMixerGroup)null, ""); } } } } public class HandItem_SwingHook : HandItem { public enum State { Idle, Flying, Latched } private bool isUsing; private bool waitForRelease; private SpriteRenderer sprite; public const string SpriteChildName = "SwingHook_Sprite"; private readonly List<RopePoint> flightWraps = new List<RopePoint>(); private Vector3 prevHook; private Vector3 prevHand; private const int MaxFlightWraps = 12; private const float CatchOnCornerDistance = 0.7f; private float flightLength; private bool reelControl; private const float RetrieveDistance = 1.2f; public static HandItem_SwingHook Active { get; private set; } public State CurrentState { get; private set; } public Vector3 HookPosition { get; private set; } public Vector3 HookVelocity { get; private set; } public bool IsOut => CurrentState != State.Idle; public bool IsTaut { get; private set; } internal IReadOnlyList<RopePoint> FlightWraps => flightWraps; private void Awake() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown if (base.interactionModules == null) { base.interactionModules = new List<Item_InteractionModule>(); } if (base.itemCosmetics == null) { base.itemCosmetics = new List<Cosmetic_Item>(); } if (base.useStats == null) { base.useStats = new List<string>(); } if (base.simpleUseModules == null) { base.simpleUseModules = new List<SimpleModule>(); } if (base.itemUseEvent == null) { base.itemUseEvent = new UnityEvent(); } if (base.firstGrabEvent == null) { base.firstGrabEvent = new UnityEvent(); } base.canUseWhileHanging = true; Transform val = ((Component)this).transform.Find("SwingHook_Sprite"); if ((Object)(object)val != (Object)null) { sprite = ((Component)val).GetComponent<SpriteRenderer>(); } } public override void Use() { ((HandItem)this).Use(); isUsing = true; } public override void StopUse() { ((HandItem)this).StopUse(); isUsing = false; waitForRelease = false; if (IsOut) { LetGo(playSound: true); } } public override void Update() { ((HandItem)this).Update(); ENT_Player player = ENT_Player.GetPlayer(); if ((Object)(object)player == (Object)null) { return; } switch (CurrentState) { case State.Idle: if (isUsing && !waitForRelease) { Throw(); } break; case State.Flying: Fly(Time.deltaTime); break; case State.Latched: WhileLatched(player, Time.deltaTime); break; } } public override void LateUpdate() { ((HandItem)this).LateUpdate(); if ((Object)(object)sprite != (Object)null) { Sprite val = (IsOut ? HookAssets.CoilSprite : HookAssets.HeldSprite); if ((Object)(object)val != (Object)null && (Object)(object)sprite.sprite != (Object)(object)val) { sprite.sprite = val; } } } private void OnDisable() { if (IsOut) { LetGo(playSound: false); } } public override bool AllowJump() { return true; } private void Throw() { //IL_001a: 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_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_003b: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)Camera.main).transform; ENT_Player player = ENT_Player.GetPlayer(); CurrentState = State.Flying; HookPosition = transform.position + transform.forward * 0.3f; HookVelocity = transform.forward * SwingHookPlugin.ThrowSpeed.Value; IsTaut = false; flightLength = 0f; reelControl = false; flightWraps.Clear(); prevHook = HookPosition; prevHand = Rope.RopeEnd(player); Active = this; GameRefs.Play("grapple:prime", ((Component)this).transform.position); } private void Fly(float dt) { //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_000e: 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) //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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: 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_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0254: 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_0121: 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_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013c: 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_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_015f: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: 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_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_0300: 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_0309: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0467: Unknown result type (might be due to invalid IL or missing references) //IL_0478: 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_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04b9: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_040a: 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_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) ENT_Player player = ENT_Player.GetPlayer(); Vector3 playerUpVector = player.GetPlayerUpVector(); Vector3 val = Rope.RopeEnd(player); for (int num = flightWraps.Count - 1; num >= 0; num--) { if (!flightWraps[num].Follow()) { flightWraps.RemoveAt(num); } } HookVelocity -= playerUpVector * SwingHookPlugin.ThrowGravity.Value * dt; Vector3 val2 = HookPosition + HookVelocity * dt; Vector3 val3 = val2 - HookPosition; RaycastHit val4 = default(RaycastHit); if (((Vector3)(ref val3)).sqrMagnitude > 1E-08f && Physics.SphereCast(HookPosition, 0.1f, ((Vector3)(ref val3)).normalized, ref val4, ((Vector3)(ref val3)).magnitude, LayerMask.op_Implicit(GameRefs.GrappleMask), (QueryTriggerInteraction)1) && !((Component)((RaycastHit)(ref val4)).collider).transform.IsChildOf(((Component)player).transform)) { if (!((Object)(object)((RaycastHit)(ref val4)).rigidbody != (Object)null) || ((RaycastHit)(ref val4)).rigidbody.isKinematic) { Latch(((RaycastHit)(ref val4)).point, ((Object)(object)((RaycastHit)(ref val4)).rigidbody != (Object)null) ? ((Component)((RaycastHit)(ref val4)).rigidbody).transform : ((Component)((RaycastHit)(ref val4)).collider).transform, ((RaycastHit)(ref val4)).point, val); return; } HookVelocity = Vector3.Reflect(HookVelocity, ((RaycastHit)(ref val4)).normal) * 0.35f; val2 = ((RaycastHit)(ref val4)).point + ((RaycastHit)(ref val4)).normal * 0.15f; GameRefs.Play("grapple:latchhit", ((RaycastHit)(ref val4)).point); } UpdateFlightWraps(player, val2, val); Vector3 val5 = ((flightWraps.Count > 0) ? flightWraps[0].Position : val); float num2 = RopeLengthFromHandTo(val, 0); float value = SwingHookPlugin.RopeLengthMax.Value; int num3 = ReelInput(player, allowInAir: false); if (num3 != 0) { reelControl = true; float num4 = SwingHookPlugin.ReelSpeed.Value * ((num3 > 0) ? 1.5f : 1f); flightLength = Mathf.Clamp(flightLength + (float)num3 * num4 * dt, 0f, value); } if (!reelControl) { flightLength = Mathf.Min(value, Mathf.Max(flightLength, num2 + Vector3.Distance(val2, val5))); } if (reelControl && flightWraps.Count == 0 && flightLength <= 1.2f) { LetGo(playSound: true); return; } float num5 = Mathf.Max(0f, flightLength - num2); Vector3 val6 = val2 - val5; float magnitude = ((Vector3)(ref val6)).magnitude; IsTaut = (IsTaut ? (magnitude >= num5 * 0.94f) : (magnitude >= num5 * 0.99f)); if (magnitude > num5 && magnitude > 0.0001f) { Vector3 val7 = val6 / magnitude; Vector3 val8 = val5 + val7 * num5; Vector3 val9 = val8 - HookPosition; RaycastHit val10 = default(RaycastHit); if (((Vector3)(ref val9)).sqrMagnitude > 1E-08f && Physics.SphereCast(HookPosition, 0.1f, ((Vector3)(ref val9)).normalized, ref val10, ((Vector3)(ref val9)).magnitude, LayerMask.op_Implicit(GameRefs.GrappleMask), (QueryTriggerInteraction)1) && !((Component)((RaycastHit)(ref val10)).collider).transform.IsChildOf(((Component)player).transform) && ((Object)(object)((RaycastHit)(ref val10)).rigidbody == (Object)null || ((RaycastHit)(ref val10)).rigidbody.isKinematic)) { Latch(((RaycastHit)(ref val10)).point, ((Object)(object)((RaycastHit)(ref val10)).rigidbody != (Object)null) ? ((Component)((RaycastHit)(ref val10)).rigidbody).transform : ((Component)((RaycastHit)(ref val10)).collider).transform, ((RaycastHit)(ref val10)).point, val); return; } val2 = val8; float num6 = Vector3.Dot(HookVelocity, val7); if (num6 > 0f) { HookVelocity -= val7 * num6; } HookVelocity *= 1f - Mathf.Clamp01(0.4f * dt); } Vector3 val11 = (HookPosition = val2); prevHook = val11; prevHand = val; if (flightWraps.Count > 0 && IsTaut && Vector3.Distance(HookPosition, flightWraps[0].Position) < 0.7f) { RopePoint ropePoint = flightWraps[0]; flightWraps.RemoveAt(0); Latch(ropePoint.Position, ropePoint.Target, ropePoint.Position, val); } } private static int ReelInput(ENT_Player player, bool allowInAir) { if (SwingHookPlugin.ReelSpeed.Value <= 0f) { return 0; } bool flag = player.IsGrounded(false); if (!flag && !allowInAir) { return 0; } bool flag2 = ((Vector2)(ref InputManager.GetVector("Move").vector)).magnitude > 0.1f; if (flag && flag2) { return 0; } if (InputManager.GetButton("Sprint").Pressed) { return -1; } if (InputManager.GetButton("Crouch").Pressed) { return 1; } return 0; } private float RopeLengthFromHandTo(Vector3 hand, int index) { //IL_0013: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) if (flightWraps.Count == 0) { return 0f; } float num = Vector3.Distance(hand, flightWraps[flightWraps.Count - 1].Position); for (int num2 = flightWraps.Count - 1; num2 > index; num2--) { num += Vector3.Distance(flightWraps[num2].Position, flightWraps[num2 - 1].Position); } return num; } private void UpdateFlightWraps(ENT_Player player, Vector3 hook, Vector3 hand) { //IL_002f: 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_0101: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_015f: 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_0106: 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_0116: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_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_004c: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_00c2: 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) if (flightWraps.Count < 12) { Vector3 val = ((flightWraps.Count > 0) ? flightWraps[0].Position : hand); Vector3 aFrom = ((flightWraps.Count > 0) ? val : prevHand); if (Rope.SweepCorner(player, aFrom, val, prevHook, hook, 0.3f, out var corner)) { Rope.SetBend(corner, hook, val); flightWraps.Insert(0, corner); } else if (flightWraps.Count > 0) { Vector3 position = flightWraps[flightWraps.Count - 1].Position; if (Rope.SweepCorner(player, position, position, prevHand, hand, 0.2f, out var corner2)) { Rope.SetBend(corner2, position, hand); flightWraps.Add(corner2); } } } if (flightWraps.Count > 0) { Vector3 playerSide = ((flightWraps.Count > 1) ? flightWraps[1].Position : hand); if (Rope.ShouldUnwrap(player, flightWraps[0], hook, playerSide)) { flightWraps.RemoveAt(0); } } if (flightWraps.Count > 0) { int num = flightWraps.Count - 1; Vector3 hookSide = ((num > 0) ? flightWraps[num - 1].Position : hook); if (Rope.ShouldUnwrap(player, flightWraps[num], hookSide, hand)) { flightWraps.RemoveAt(num); } } } private void Latch(Vector3 anchor, Transform stuckTo, Vector3 soundAt, Vector3 hand) { //IL_0007: 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_0016: 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_004d: 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_0080: Unknown result type (might be due to invalid IL or missing references) CurrentState = State.Latched; float num = Vector3.Distance(anchor, (flightWraps.Count > 0) ? flightWraps[0].Position : hand); float length = Mathf.Max(SwingHookPlugin.MinRopeLength.Value, RopeLengthFromHandTo(hand, 0) + num); Rope.Attach(this, anchor, length, stuckTo, flightWraps); flightWraps.Clear(); GameRefs.Play("grapple:latch", ((Component)this).transform.position); GameRefs.Play("grapple:latchhit", soundAt); } private void WhileLatched(ENT_Player player, float dt) { //IL_002a: 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_0043: Unknown result type (might be due to invalid IL or missing references) if (InputManager.GetButton("Jump").Down && !player.IsGrounded(true)) { waitForRelease = true; LetGo(playSound: true); ((GameEntity)player).AddForce(player.GetPlayerUpVector() * GameRefs.JumpForce * SwingHookPlugin.ReleaseHop.Value, ""); return; } int num = ReelInput(player, allowInAir: true); if (num != 0) { Rope.ChangeLength((float)num * SwingHookPlugin.ReelSpeed.Value * ((num > 0) ? 1.5f : 1f) * dt); } } public void LetGo(bool playSound) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (CurrentState != State.Idle) { CurrentState = State.Idle; flightWraps.Clear(); Rope.Detach(this); if ((Object)(object)Active == (Object)(object)this) { Active = null; } if (playSound) { GameRefs.Play("grapple:letgo", ((Component)this).transform.position); } } } public bool TryGetGripOnOverlay(out Vector3 point) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_0047: Unknown result type (might be due to invalid IL or missing references) point = Vector3.zero; if ((Object)(object)sprite == (Object)null || !((Renderer)sprite).enabled) { return false; } Vector2 val = HookAssets.GripPixels / 100f; if (sprite.flipX) { val.x = 0f - val.x; } point = ((Component)sprite).transform.TransformPoint(Vector2.op_Implicit(val)); return true; } } internal static class HookAssets { private static bool tried; public static readonly Vector2 GripPixels = new Vector2(20f, -26f); public const float SpritePixelsPerUnit = 100f; public static Mesh HookMesh { get; private set; } public static Texture2D HookTexture { get; private set; } public static Texture2D RopeTexture { get; private set; } public static Sprite HeldSprite { get; private set; } public static Sprite CoilSprite { get; private set; } public static bool Load() { if (tried) { return (Object)(object)HookMesh != (Object)null; } tried = true; try { string assetDir = SwingHookPlugin.AssetDir; HookMesh = ModelLoader.LoadObj(Path.Combine(assetDir, "grappling_hook.obj")); HookTexture = ModelLoader.LoadTexture(Path.Combine(assetDir, "grappling_hook_albedo.png"), repeat: false); RopeTexture = ModelLoader.LoadTexture(Path.Combine(assetDir, "rope_albedo.png"), repeat: true); Object.DontDestroyOnLoad((Object)(object)HookMesh); Object.DontDestroyOnLoad((Object)(object)HookTexture); Object.DontDestroyOnLoad((Object)(object)RopeTexture); HeldSprite = LoadSprite(Path.Combine(assetDir, "held_hook.png"), "SwingHook_Held"); CoilSprite = LoadSprite(Path.Combine(assetDir, "held_coil.png"), "SwingHook_Coil"); SwingHookPlugin.Log.LogInfo((object)$"Hook model loaded ({HookMesh.vertexCount} verts)"); return true; } catch (Exception arg) { HookMesh = null; SwingHookPlugin.Log.LogError((object)$"Couldn't load the hook model from {SwingHookPlugin.AssetDir}: {arg}"); return false; } } private static Sprite LoadSprite(string path, string name) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (!File.Exists(path)) { return null; } Texture2D val = ModelLoader.LoadTexture(path, repeat: false); Object.DontDestroyOnLoad((Object)(object)val); Sprite obj = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); ((Object)obj).name = name; Object.DontDestroyOnLoad((Object)(object)obj); return obj; } } internal static class ModelLoader { public static Mesh LoadObj(string path) { //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: 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_0213: 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) List<Vector3> list = new List<Vector3>(); List<Vector2> list2 = new List<Vector2>(); List<Vector3> list3 = new List<Vector3>(); List<Vector3> list4 = new List<Vector3>(); List<Vector2> list5 = new List<Vector2>(); List<Vector3> list6 = new List<Vector3>(); List<int> list7 = new List<int>(); Dictionary<string, int> dictionary = new Dictionary<string, int>(); CultureInfo invariantCulture = CultureInfo.InvariantCulture; string[] array = File.ReadAllLines(path); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length == 0 || text[0] == '#') { continue; } string[] array2 = text.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries); switch (array2[0]) { case "v": list.Add(new Vector3(0f - float.Parse(array2[1], invariantCulture), float.Parse(array2[2], invariantCulture), float.Parse(array2[3], invariantCulture))); break; case "vt": list2.Add(new Vector2(float.Parse(array2[1], invariantCulture), float.Parse(array2[2], invariantCulture))); break; case "vn": list3.Add(new Vector3(0f - float.Parse(array2[1], invariantCulture), float.Parse(array2[2], invariantCulture), float.Parse(array2[3], invariantCulture))); break; case "f": { List<int> list8 = new List<int>(); for (int j = 1; j < array2.Length; j++) { if (!dictionary.TryGetValue(array2[j], out var value)) { string[] array3 = array2[j].Split('/'); int index = int.Parse(array3[0]) - 1; int num = ((array3.Length > 1 && array3[1].Length > 0) ? (int.Parse(array3[1]) - 1) : (-1)); int num2 = ((array3.Length > 2 && array3[2].Length > 0) ? (int.Parse(array3[2]) - 1) : (-1)); value = list4.Count; list4.Add(list[index]); list5.Add((num >= 0) ? list2[num] : Vector2.zero); list6.Add((num2 >= 0) ? list3[num2] : Vector3.up); dictionary[array2[j]] = value; } list8.Add(value); } for (int k = 1; k + 1 < list8.Count; k++) { list7.Add(list8[0]); list7.Add(list8[k + 1]); list7.Add(list8[k]); } break; } } } Mesh val = new Mesh { name = Path.GetFileNameWithoutExtension(path) }; if (list4.Count > 65000) { val.indexFormat = (IndexFormat)1; } val.SetVertices(list4); val.SetUVs(0, list5); val.SetNormals(list6); val.SetTriangles(list7, 0); val.RecalculateBounds(); val.RecalculateTangents(); return val; } public static Texture2D LoadTexture(string path, bool repeat) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0019: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); byte[] array = File.ReadAllBytes(path); ImageConversion.LoadImage(val, array, false); ((Object)val).name = Path.GetFileNameWithoutExtension(path); ((Texture)val).filterMode = (FilterMode)0; ((Texture)val).wrapMode = (TextureWrapMode)(!repeat); return val; } public static Material MakeMaterial(Texture2D tex, string name, Material template = null) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)template == (Object)null) { template = FindTemplate(); } Material val; if ((Object)(object)template != (Object)null) { val = new Material(template); SwingHookPlugin.Log.LogInfo((object)(name + ": using game shader '" + ((Object)template.shader).name + "' (from material '" + ((Object)template).name + "')")); } else { Shader val2 = Shader.Find("Unlit/Texture") ?? Shader.Find("Standard") ?? Shader.Find("Sprites/Default"); val = new Material(val2); SwingHookPlugin.Log.LogWarning((object)(name + ": no game material found, falling back to '" + ((val2 != null) ? ((Object)val2).name : null) + "'")); } ((Object)val).name = name; val.mainTexture = (Texture)(object)tex; if (val.HasProperty("_Wiggle")) { val.SetFloat("_Wiggle", 0f); } if (val.HasProperty("_Color")) { val.SetColor("_Color", Color.white); } return val; } private static Material FindTemplate() { Item_Object[] array = Object.FindObjectsByType<Item_Object>((FindObjectsSortMode)0); MeshRenderer[] componentsInChildren; for (int i = 0; i < array.Length; i++) { componentsInChildren = ((Component)array[i]).GetComponentsInChildren<MeshRenderer>(); for (int j = 0; j < componentsInChildren.Length; j++) { Material sharedMaterial = ((Renderer)componentsInChildren[j]).sharedMaterial; if ((Object)(object)sharedMaterial != (Object)null && (Object)(object)sharedMaterial.mainTexture != (Object)null && sharedMaterial.renderQueue <= 2500) { return sharedMaterial; } } } componentsInChildren = Object.FindObjectsByType<MeshRenderer>((FindObjectsSortMode)0); foreach (MeshRenderer obj in componentsInChildren) { Material sharedMaterial2 = ((Renderer)obj).sharedMaterial; if (((Renderer)obj).lightmapIndex < 0 && (Object)(object)sharedMaterial2 != (Object)null && (Object)(object)sharedMaterial2.mainTexture != (Object)null && sharedMaterial2.renderQueue <= 2500) { return sharedMaterial2; } } return null; } } internal class RopePoint { public Vector3 Position; public Transform Target; public Vector3 Local; public bool HasTarget; public Vector3 BendAxis; public bool HasBend; public Vector3 OutDir; public RopePoint(Vector3 position, Transform target) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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) Position = position; Target = target; HasTarget = (Object)(object)target != (Object)null; if (HasTarget) { Local = target.InverseTransformPoint(position); } } public void MoveTo(Vector3 position) { //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_0024: 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) Position = position; if (HasTarget && (Object)(object)Target != (Object)null) { Local = Target.InverseTransformPoint(position); } } public bool Follow() { //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_003e: Unknown result type (might be due to invalid IL or missing references) if (!HasTarget) { return true; } if ((Object)(object)Target == (Object)null || !((Component)Target).gameObject.activeInHierarchy) { return false; } Position = Target.TransformPoint(Local); return true; } } internal static class Rope { public const float VelocityUnitsPerMetre = 1f / 175f; private const int MaxPoints = 64; private const float SameContactDistance = 0.05f; private const float CoilSpacing = 0.08f; public const float Thickness = 0.04f; public const float WrapOffset = 0.099999994f; public static HandItem_SwingHook Owner; public static float Length; public static readonly List<RopePoint> Points = new List<RopePoint>(); public static Vector3 PivotVelocity; private static Vector3 lastPivot; private static RopePoint lastPivotPoint; private static Vector3 lastPlayerPos; private static bool hasLastPlayerPos; private static readonly RaycastHit[] hits = (RaycastHit[])(object)new RaycastHit[16]; public static bool Active { get { if ((Object)(object)Owner != (Object)null && ((Behaviour)Owner).isActiveAndEnabled) { return Points.Count > 0; } return false; } } public static Vector3 Anchor => Points[0].Position; public static Vector3 Pivot => Points[Points.Count - 1].Position; public static float WrappedLength { get { //IL_0018: 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) float num = 0f; for (int i = 1; i < Points.Count; i++) { num += Vector3.Distance(Points[i - 1].Position, Points[i].Position); } return num; } } public static float FreeLength => Mathf.Max(0.3f, Length - WrappedLength); public static void Attach(HandItem_SwingHook owner, Vector3 anchor, float length, Transform stuckTo, IEnumerable<RopePoint> wraps = null) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) Owner = owner; Length = length; Points.Clear(); Points.Add(new RopePoint(anchor, stuckTo)); if (wraps != null) { Points.AddRange(wraps); } PivotVelocity = Vector3.zero; lastPivotPoint = Points[Points.Count - 1]; lastPivot = lastPivotPoint.Position; hasLastPlayerPos = false; } public static void Detach(HandItem_SwingHook owner) { //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) if (!((Object)(object)Owner != (Object)(object)owner)) { Owner = null; Points.Clear(); PivotVelocity = Vector3.zero; } } public static void ChangeLength(float delta) { float num = WrappedLength + SwingHookPlugin.MinRopeLength.Value; Length = Mathf.Clamp(Length + delta, Mathf.Min(num, Length), Mathf.Max(SwingHookPlugin.RopeLengthMax.Value, Length)); } public static void Follow(float dt) { //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_007d: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_009e: Unknown result type (might be due to invalid IL or missing references) if (!Points[0].Follow()) { Owner?.LetGo(playSound: true); return; } for (int num = Points.Count - 1; num >= 1; num--) { if (!Points[num].Follow()) { Points.RemoveAt(num); } } RopePoint ropePoint = Points[Points.Count - 1]; Vector3 val = ropePoint.Position - lastPivot; PivotVelocity = ((ropePoint != lastPivotPoint || ((Vector3)(ref val)).magnitude > 5f || dt <= 0f) ? Vector3.zero : (val / dt)); lastPivot = ropePoint.Position; lastPivotPoint = ropePoint; } public static void UpdateWraps(ENT_Player player) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_002e: 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) Vector3 val = RopeEnd(player); Vector3 fromPlayer = (hasLastPlayerPos ? lastPlayerPos : val); if (Points.Count < 64) { TryWrap(player, fromPlayer, val); } TryUnwrap(player, val); } public static void EndStep(ENT_Player player) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) lastPlayerPos = RopeEnd(player); hasLastPlayerPos = true; } public static Vector3 RopeEnd(ENT_Player p) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) return ((Component)p).transform.position + p.GetPlayerUpVector() * 0.3f; } private static void TryWrap(ENT_Player player, Vector3 fromPlayer, Vector3 toPlayer) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) Vector3 pivot = Pivot; if (SweepCorner(player, pivot, pivot, fromPlayer, toPlayer, 0.2f, out var corner)) { StackOnCoils(corner, Points.Count - 1); SetBend(corner, pivot, toPlayer); Points.Add(corner); } } private static void StackOnCoils(RopePoint corner, int skip) { //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_0074: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 64; i++) { RopePoint ropePoint = null; for (int j = 1; j < Points.Count; j++) { if (j != skip && !(Points[j].OutDir == Vector3.zero) && Vector3.Distance(Points[j].Position, corner.Position) < 0.072f) { ropePoint = Points[j]; break; } } if (ropePoint == null) { break; } corner.MoveTo(ropePoint.Position + ropePoint.OutDir * 0.08f); corner.OutDir = ropePoint.OutDir; } } private static void TryUnwrap(ENT_Player player, Vector3 playerPos) { //IL_003d: 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) if (Points.Count >= 2) { RopePoint corner = Points[Points.Count - 1]; if (ShouldUnwrap(player, corner, Points[Points.Count - 2].Position, playerPos)) { Points.RemoveAt(Points.Count - 1); } } } public static bool SweepCorner(ENT_Player player, Vector3 aFrom, Vector3 aTo, Vector3 bFrom, Vector3 bTo, float minFromB, out RopePoint corner) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0087: 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_008e: 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_0024: 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_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_0037: 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_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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_0055: 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_0069: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0112: 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_013c: 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_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_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_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) //IL_0153: 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_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0184: 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_018b: 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_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: 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_01a4: 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_0128: 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_01b4: 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_01ce: 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_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: 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) corner = null; if (SegmentBlocked(player, aFrom, aTo, bFrom, bTo, 0f, minFromB, out var hit)) { for (float num = 2f; num <= 32f; num *= 2f) { Vector3 val = aTo + (aFrom - aTo) * num; Vector3 val2 = bTo + (bFrom - bTo) * num; if (!SegmentBlocked(player, val, aTo, val2, bTo, 0f, minFromB, out hit)) { aFrom = val; bFrom = val2; break; } } } float num2 = Vector3.Distance(aFrom, aTo) + Vector3.Distance(bFrom, bTo); int num3 = 2 + Mathf.Min(16, Mathf.RoundToInt(num2 * 10f)); float num4 = -1f; for (int i = 0; i < num3; i++) { float num5 = ((num3 > 1) ? ((float)i / (float)(num3 - 1)) : 1f); if (!SegmentBlocked(player, aFrom, aTo, bFrom, bTo, num5, minFromB, out var hit2)) { num4 = num5; continue; } if (num4 >= 0f) { float num6 = num4; float num7 = num5; for (int j = 0; j < 10; j++) { float num8 = (num6 + num7) * 0.5f; if (SegmentBlocked(player, aFrom, aTo, bFrom, bTo, num8, minFromB, out var hit3)) { num7 = num8; hit2 = hit3; } else { num6 = num8; } } Vector3 val3 = Vector3.Lerp(aFrom, aTo, num5); Vector3 val4 = Vector3.Lerp(bFrom, bTo, num5); Vector3 val5 = ClosestPointOnSegment(val3, val4, ((RaycastHit)(ref hit2)).point); Vector3 val6 = ClosestPointOnSegment(Vector3.Lerp(aFrom, aTo, num4), Vector3.Lerp(bFrom, bTo, num4), ((RaycastHit)(ref hit2)).point); Vector3 val7 = val4 - val3; Vector3 normalized = ((Vector3)(ref val7)).normalized; Vector3 val8 = Vector3.ProjectOnPlane(val6 - val5, normalized); Vector3 val9 = ((((Vector3)(ref val8)).sqrMagnitude > 1E-10f) ? ((Vector3)(ref val8)).normalized : Vector3.zero) + 0.5f * ((RaycastHit)(ref hit2)).normal; corner = MakeCorner(hit2, (((Vector3)(ref val9)).sqrMagnitude > 1E-06f) ? ((Vector3)(ref val9)).normalized : ((RaycastHit)(ref hit2)).normal); } else { corner = MakeCorner(hit2, ((RaycastHit)(ref hit2)).normal); } if (Vector3.Distance(corner.Position, aTo) < 0.05f) { corner = null; return false; } return true; } return false; } private static bool SegmentBlocked(ENT_Player player, Vector3 aFrom, Vector3 aTo, Vector3 bFrom, Vector3 bTo, float t, float minFromB, out RaycastHit hit) { //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_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_000b: 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.Lerp(aFrom, aTo, t); Vector3 val2 = Vector3.Lerp(bFrom, bTo, t); float num = Vector3.Distance(val, val2); if (Cast(player, val, val2, out hit) && ((RaycastHit)(ref hit)).distance > 0.03f) { return ((RaycastHit)(ref hit)).distance < num - minFromB; } return false; } private static RopePoint MakeCorner(RaycastHit hit, Vector3 outDir) { //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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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) Transform target = (((Object)(object)((RaycastHit)(ref hit)).rigidbody != (Object)null) ? ((Component)((RaycastHit)(ref hit)).rigidbody).transform : ((Component)((RaycastHit)(ref hit)).collider).transform); return new RopePoint(((RaycastHit)(ref hit)).point + outDir * 0.099999994f, target) { OutDir = outDir }; } public static Vector3 BendAxis(Vector3 a, Vector3 corner, Vector3 b) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) return Vector3.Cross(corner - a, b - corner); } public static void SetBend(RopePoint corner, Vector3 hookSide, Vector3 playerSide) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_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) Vector3 val = BendAxis(hookSide, corner.Position, playerSide); corner.HasBend = ((Vector3)(ref val)).sqrMagnitude > 1E-08f; if (corner.HasBend) { corner.BendAxis = ((Vector3)(ref val)).normalized; } } public static bool ShouldUnwrap(ENT_Player player, RopePoint corner, Vector3 hookSide, Vector3 playerSide) { //IL_002a: 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_0008: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (corner.HasBend && Vector3.Dot(BendAxis(hookSide, corner.Position, playerSide), corner.BendAxis) > 0f) { return false; } return !Blocked(player, hookSide, playerSide); } public static bool Blocked(ENT_Player player, Vector3 a, Vector3 b) { //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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (!Cast(player, a, b, out var best)) { return Cast(player, b, a, out best); } return true; } public static bool Cast(ENT_Player player, Vector3 a, Vector3 b, out RaycastHit best) { //IL_0001: 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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_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) best = default(RaycastHit); Vector3 val = b - a; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude < 0.001f) { return false; } int num = Physics.SphereCastNonAlloc(a, 0.04f, val / magnitude, hits, magnitude, LayerMask.op_Implicit(GameRefs.GrappleMask), (QueryTriggerInteraction)1); float num2 = float.MaxValue; for (int i = 0; i < num; i++) { if (!((Object)(object)((RaycastHit)(ref hits[i])).collider == (Object)null) && !((Component)((RaycastHit)(ref hits[i])).collider).transform.IsChildOf(((Component)player).transform) && (!(((RaycastHit)(ref hits[i])).distance <= 0f) || !(((RaycastHit)(ref hits[i])).point == Vector3.zero)) && ((RaycastHit)(ref hits[i])).distance < num2) { num2 = ((RaycastHit)(ref hits[i])).distance; best = hits[i]; } } return num2 < float.MaxValue; } public static Vector3 ClosestPointOnSegment(Vector3 a, Vector3 b, Vector3 p) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_000f: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) Vector3 val = b - a; float num = Mathf.Clamp01(Vector3.Dot(p - a, val) / Mathf.Max(1E-06f, ((Vector3)(ref val)).sqrMagnitude)); return a + val * num; } } [HarmonyPatch(typeof(ENT_Player), "Movement")] internal static class RopePhysics { private static readonly FieldRef<ENT_Player, Vector3> Vel = AccessTools.FieldRefAccess<ENT_Player, Vector3>("vel"); private static readonly FieldRef<ENT_Player, float> GravityMult = AccessTools.FieldRefAccess<ENT_Player, float>("gravityMult"); private static void Prefix(ENT_Player __instance) { if (Rope.Active && !__instance.noclip) { Rope.Follow(Time.fixedDeltaTime); if (Rope.Active) { Rope.UpdateWraps(__instance); SwingAssist(__instance); RemoveStretch(__instance); } } } private static void Postfix(ENT_Player __instance) { //IL_0011: 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_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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_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) if (Rope.Active && !__instance.noclip) { Vector3 val = Rope.RopeEnd(__instance) - Rope.Pivot; float magnitude = ((Vector3)(ref val)).magnitude; float num = magnitude - Rope.FreeLength; if (num > 0.01f) { Vector3 val2 = val / magnitude; __instance.cCon.Move(-val2 * Mathf.Min(num, 0.5f)); RemoveStretch(__instance); } Rope.EndStep(__instance); } } private static void SwingAssist(ENT_Player p) { //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_002d: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_006b: 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_007c: 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_0086: 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_009a: 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) float value = SwingHookPlugin.SwingAssist.Value; if (!(value <= 0f) && !p.IsGrounded(false)) { Vector3 val = Rope.Pivot - Rope.RopeEnd(p); Vector3 playerUpVector = p.GetPlayerUpVector(); if (!(Vector3.Dot(val, playerUpVector) <= 0f) && !(((Vector3)(ref val)).sqrMagnitude < 0.0001f)) { Vector3 val2 = Vector3.ProjectOnPlane(p.GetPlayerGravityVector() * (p.gravity * GravityMult.Invoke(p)) * Time.fixedDeltaTime, ((Vector3)(ref val)).normalized); ref Vector3 reference = ref Vel.Invoke(p); reference += val2 * value; } } } private static void RemoveStretch(ENT_Player p) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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) Vector3 val = Rope.RopeEnd(p) - Rope.Pivot; float magnitude = ((Vector3)(ref val)).magnitude; if (!(magnitude < Rope.FreeLength) && !(magnitude < 0.0001f)) { Vector3 val2 = val / magnitude; ref Vector3 reference = ref Vel.Invoke(p); Vector3 val3 = Rope.PivotVelocity * (1f / 175f); float num = Vector3.Dot(reference - val3, val2); if (num > 0f) { reference -= val2 * num; } } } } internal class SlackRope { private const int N = 64; private const int Iterations = 12; private const float SubStep = 1f / 120f; private const int MaxSubSteps = 3; private const float Gravity = 15f; private const float Damping = 0.985f; private const float GroundFriction = 0.8f; private const float Radius = 0.03f; private const float ResetJump = 3f; private readonly Vector3[] pos = (Vector3[])(object)new Vector3[64]; private readonly Vector3[] prev = (Vector3[])(object)new Vector3[64]; private bool started; private Vector3 lastA; private Vector3 lastB; private float pending; private static readonly Collider[] overlaps = (Collider[])(object)new Collider[16]; private static SphereCollider probe; public void Reset() { started = false; } public void Step(ENT_Player player, Vector3 a, Vector3 b, float length, Vector3 up, float dt) { //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_0027: 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_003a: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_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_006f: 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_0076: 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_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) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_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_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) //IL_0117: 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_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_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_0167: 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_016d: 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_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0184: 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_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018b: 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_01b1: Unknown result type (might be due to invalid IL or missing references) length = Mathf.Max(length, Vector3.Distance(a, b) * 1.001f); float seg = length / 63f; if (!started || Vector3.Distance(a, lastA) > 3f || Vector3.Distance(b, lastB) > 3f) { for (int i = 0; i < 64; i++) { pos[i] = (prev[i] = Vector3.Lerp(a, b, (float)i / 63f)); } started = true; pending = 0f; } lastA = a; lastB = b; pending = Mathf.Min(pending + dt, 0.025000002f); while (pending >= 1f / 120f) { pending -= 1f / 120f; Vector3 val = -up * 0.0010416667f; for (int j = 1; j < 63; j++) { Vector3 val2 = pos[j]; ref Vector3 reference = ref pos[j]; reference += (val2 - prev[j]) * 0.985f + val; prev[j] = val2; } pos[0] = (prev[0] = a); pos[63] = (prev[63] = b); for (int k = 0; k < 12; k++) { for (int l = 0; l < 63; l++) { Link(l, seg); } Tethers(a, b, seg); } Collide(player); } } public void AddTo(List<Vector3> path) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 64; i++) { path.Add(pos[i]); } } private void Link(int i, float seg) { //IL_003a: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) float num = ((i == 0) ? 0f : 1f); float num2 = ((i + 1 == 63) ? 0f : 1f); float num3 = num + num2; if (!(num3 <= 0f)) { Vector3 val = pos[i + 1] - pos[i]; float magnitude = ((Vector3)(ref val)).magnitude; if (!(magnitude < 1E-06f)) { Vector3 val2 = val * ((magnitude - seg) / (magnitude * num3)); ref Vector3 reference = ref pos[i]; reference += val2 * num; ref Vector3 reference2 = ref pos[i + 1]; reference2 -= val2 * num2; } } } private void Tethers(Vector3 a, Vector3 b, float seg) { //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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) for (int i = 1; i < 63; i++) { float num = (float)i * seg; float num2 = (float)(63 - i) * seg; Vector3 val = pos[i] - a; if (((Vector3)(ref val)).sqrMagnitude > num * num) { pos[i] = a + ((Vector3)(ref val)).normalized * num; } val = pos[i] - b; if (((Vector3)(ref val)).sqrMagnitude > num2 * num2) { pos[i] = b + ((Vector3)(ref val)).normalized * num2; } } } private void Collide(ENT_Player player) { //IL_0026: 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_003c: 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) for (int i = 1; i < 63; i++) { if (PushOut(player, ref pos[i])) { prev[i] = Vector3.Lerp(prev[i], pos[i], 0.8f); } } } private static bool PushOut(ENT_Player player, ref Vector3 p) { //IL_0012: 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_009a: 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_00ad: 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_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_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) SphereCollider val = Probe(); val.radius = 0.03f; int num = Physics.OverlapSphereNonAlloc(p, 0.03f, overlaps, LayerMask.op_Implicit(GameRefs.GrappleMask), (QueryTriggerInteraction)1); bool result = false; Vector3 val3 = default(Vector3); float num2 = default(float); for (int i = 0; i < num; i++) { Collider val2 = overlaps[i]; if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2 == (Object)(object)val) && (!((Object)(object)player != (Object)null) || !((Component)val2).transform.IsChildOf(((Component)player).transform)) && (!((Object)(object)val2.attachedRigidbody != (Object)null) || val2.attachedRigidbody.isKinematic) && Physics.ComputePenetration((Collider)(object)val, p, Quaternion.identity, val2, ((Component)val2).transform.position, ((Component)val2).transform.rotation, ref val3, ref num2)) { p += val3 * (num2 + 0.002f); result = true; } } return result; } private static SphereCollider Probe() { //IL_0018: 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: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)probe != (Object)null) { return probe; } GameObject val = new GameObject("SwingHook_SlackRopeProbe"); Object.DontDestroyOnLoad((Object)val); val.layer = 2; val.tr