Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Quads Ziplines v0.3.2
plugins/Ziplines.dll
Decompiled 18 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; 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 System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using DHack.Shared; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json.Linq; using UnityEngine; using UnityEngine.Audio; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyMetadata("AI_Assisted_Creation", "This assembly was partially or fully created with the assistance of Generative AI (Claude Code).")] [assembly: AssemblyMetadata("AI_Model_Vendor", "Anthropic")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("0.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 Ziplines { internal static class Grip { private static GameObject _root; private static Transform _axe; private static Transform _bar; private static Transform _left; private static Transform _right; private static Transform _block; private static Transform _wheel; public const float HandleDrop = 0.42f; private static Material _wood; private static Material _iron; public static bool IsAxe => (Object)(object)_axe != (Object)null; public static ItemData FindAxe(Player player) { return (from i in ((Humanoid)player).GetInventory().GetAllItems() where (Object)(object)i.m_dropPrefab != (Object)null && (int)i.m_shared.m_skillType == 7 && i.m_shared.m_damages.m_chop > 0f orderby ((Humanoid)player).IsItemEquiped(i) descending, i.m_shared.m_damages.m_chop descending select i).FirstOrDefault(); } public static void Begin(Player player, ItemData axe) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown End(); MakeMaterials(); _root = new GameObject("ZipGrip"); if (axe == null || !BuildAxe(axe)) { _block = Prim((PrimitiveType)3, "Block", _wood); _wheel = Prim((PrimitiveType)2, "Wheel", _iron); _left = Prim((PrimitiveType)2, "StrapL", _iron); _right = Prim((PrimitiveType)2, "StrapR", _iron); _bar = Prim((PrimitiveType)2, "Bar", _wood); } } public static void End() { if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } _root = null; _axe = (_bar = (_left = (_right = (_block = (_wheel = null))))); } public static void Update(Transform carriage, Vector3 rope, Vector3 hands) { //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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00b7: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0116: 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_0118: 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_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0146: 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_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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) if (!((Object)(object)_root == (Object)null)) { Vector3 up = Vector3.up; Vector3 val = Vector3.ProjectOnPlane(carriage.forward, up); Vector3 normalized = ((Vector3)(ref val)).normalized; Vector3 val2 = Vector3.Cross(up, normalized); if ((Object)(object)_axe != (Object)null) { _axe.position = hands; _axe.rotation = Quaternion.LookRotation(normalized, up); return; } Vector3 val3 = hands + up * 0.04f; Stretch(_bar, val3 - val2 * 0.26f, val3 + val2 * 0.26f, 0.022f); Vector3 a = rope - up * 0.07f; Stretch(_left, a, val3 - val2 * 0.26f, 0.008f); Stretch(_right, a, val3 + val2 * 0.26f, 0.008f); _block.position = rope - up * 0.04f; _block.rotation = Quaternion.LookRotation(normalized, up); _block.localScale = new Vector3(0.09f, 0.09f, 0.16f); _wheel.position = rope + up * 0.045f; _wheel.rotation = Quaternion.LookRotation(val2, up) * Quaternion.Euler(0f, 0f, 90f); _wheel.localScale = new Vector3(0.14f, 0.012f, 0.14f); } } private static Transform Prim(PrimitiveType shape, string name, Material material) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.CreatePrimitive(shape); ((Object)val).name = name; Object.Destroy((Object)(object)val.GetComponent<Collider>()); val.GetComponent<Renderer>().sharedMaterial = material; val.transform.SetParent(_root.transform, false); return val.transform; } private static void Stretch(Transform t, Vector3 a, Vector3 b, float radius) { //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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_002f: 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_003b: 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) Vector3 val = b - a; if (!(((Vector3)(ref val)).sqrMagnitude < 1E-06f)) { t.position = (a + b) * 0.5f; t.rotation = Quaternion.FromToRotation(Vector3.up, ((Vector3)(ref val)).normalized); t.localScale = new Vector3(radius * 2f, ((Vector3)(ref val)).magnitude * 0.5f, radius * 2f); } } private static void MakeMaterials() { //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown if ((Object)(object)_wood != (Object)null && (Object)(object)_iron != (Object)null) { return; } Material val = null; GameObject val2 = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab("Wood") : null); if ((Object)(object)val2 != (Object)null) { Renderer[] componentsInChildren = val2.GetComponentsInChildren<Renderer>(true); foreach (Renderer val3 in componentsInChildren) { val = val ?? ((IEnumerable<Material>)val3.sharedMaterials).FirstOrDefault((Func<Material, bool>)((Material m) => (Object)(object)m != (Object)null && ((Object)m).name == "wood_item")); } } if ((Object)(object)val == (Object)null) { Shader val4 = Shader.Find("Standard") ?? Shader.Find("Sprites/Default"); if ((Object)(object)val4 == (Object)null) { return; } val = new Material(val4); } _wood = Plain(val, new Color(0.52f, 0.35f, 0.2f), 0.05f); _iron = Plain(val, new Color(0.17f, 0.17f, 0.18f), 0.5f); } private static Material Plain(Material basis, Color color, float metal) { //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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown Material val = new Material(basis) { color = color }; if (val.HasProperty("_MainTex")) { val.mainTexture = null; } if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", 0.2f); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", metal); } return val; } private static bool BuildAxe(ItemData axe) { //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_0179: 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_0182: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: 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_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: 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_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0237: 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_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0267: 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_0281: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: 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_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: 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_0313: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_0319: 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_0320: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Expected O, but got Unknown //IL_0441: Unknown result type (might be due to invalid IL or missing references) //IL_0448: Expected O, but got Unknown //IL_0463: Unknown result type (might be due to invalid IL or missing references) //IL_0471: 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_0489: Unknown result type (might be due to invalid IL or missing references) //IL_048b: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_0499: Unknown result type (might be due to invalid IL or missing references) //IL_04c6: Unknown result type (might be due to invalid IL or missing references) //IL_04cd: Expected O, but got Unknown //IL_04ea: Unknown result type (might be due to invalid IL or missing references) //IL_04ef: Unknown result type (might be due to invalid IL or missing references) //IL_04f4: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Unknown result type (might be due to invalid IL or missing references) //IL_050c: Unknown result type (might be due to invalid IL or missing references) //IL_0511: Unknown result type (might be due to invalid IL or missing references) //IL_0515: Unknown result type (might be due to invalid IL or missing references) //IL_0528: Unknown result type (might be due to invalid IL or missing references) //IL_052d: Unknown result type (might be due to invalid IL or missing references) //IL_0531: Unknown result type (might be due to invalid IL or missing references) GameObject dropPrefab = axe.m_dropPrefab; LODGroup componentInChildren = dropPrefab.GetComponentInChildren<LODGroup>(); Renderer[] array = ((componentInChildren != null && componentInChildren.GetLODs().Length != 0) ? componentInChildren.GetLODs()[0].renderers : dropPrefab.GetComponentsInChildren<Renderer>()); List<(MeshFilter, MeshRenderer, Matrix4x4)> list = new List<(MeshFilter, MeshRenderer, Matrix4x4)>(); List<Vector3> points = new List<Vector3>(); Renderer[] array2 = array; foreach (Renderer val in array2) { MeshFilter val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<MeshFilter>() : null); if ((Object)(object)val2 == (Object)null || (Object)(object)val2.sharedMesh == (Object)null) { continue; } MeshRenderer val3 = (MeshRenderer)(object)((val is MeshRenderer) ? val : null); if (val3 != null && !(val is ParticleSystemRenderer)) { Matrix4x4 item = dropPrefab.transform.worldToLocalMatrix * ((Component)val2).transform.localToWorldMatrix; list.Add((val2, val3, item)); Vector3[] vertices = val2.sharedMesh.vertices; int num = Mathf.Max(1, vertices.Length / 800); for (int j = 0; j < vertices.Length; j += num) { points.Add(((Matrix4x4)(ref item)).MultiplyPoint3x4(vertices[j])); } } } if (list.Count == 0 || points.Count < 4) { return false; } Bounds val4 = default(Bounds); ((Bounds)(ref val4))..ctor(points[0], Vector3.zero); foreach (Vector3 item3 in points) { ((Bounds)(ref val4)).Encapsulate(item3); } int num2 = ((!(((Bounds)(ref val4)).size.x >= ((Bounds)(ref val4)).size.y) || !(((Bounds)(ref val4)).size.x >= ((Bounds)(ref val4)).size.z)) ? ((((Bounds)(ref val4)).size.y >= ((Bounds)(ref val4)).size.z) ? 1 : 2) : 0); Vector3 axis = (Vector3)(num2 switch { 1 => Vector3.up, 0 => Vector3.right, _ => Vector3.forward, }); float low = Vector3.Dot(((Bounds)(ref val4)).min, axis); float num3 = Vector3.Dot(((Bounds)(ref val4)).max, axis); float length = Mathf.Max(0.05f, num3 - low); Vector3 val5 = ((num2 == 0) ? Vector3.up : Vector3.right); Vector3 val6 = ((num2 == 2) ? Vector3.up : Vector3.forward); if (num2 == 1) { val5 = Vector3.right; val6 = Vector3.forward; } float num4 = Mathf.Max(Spread(top: true, val5), Spread(top: true, val6)); float num5 = Mathf.Max(Spread(top: false, val5), Spread(top: false, val6)); Vector3 val7 = ((num4 >= num5) ? axis : (-axis)); bool flag = num4 >= num5; Vector3 val8 = ((Spread(flag, val5) >= Spread(flag, val6)) ? val5 : val6); Vector3 val9 = Vector3.ProjectOnPlane(val8, val7); if (((Vector3)(ref val9)).sqrMagnitude < 0.01f) { val9 = Vector3.ProjectOnPlane(val5, val7); } Quaternion val10 = Quaternion.LookRotation(((Vector3)(ref val9)).normalized, val7); Quaternion val11 = Quaternion.Inverse(val10); float num6 = Mathf.Min(1f, 0.95f / length); float num7 = 0.55f; float num8 = (flag ? (1f - num7) : num7); Vector3 val12 = Vector3.zero; int num9 = 0; foreach (Vector3 item4 in points) { float num10 = (Vector3.Dot(item4, axis) - low) / length; if (!(Mathf.Abs(num10 - num8) > 0.07f)) { val12 += item4; num9++; } } Vector3 val13 = ((num9 > 0) ? (val12 / (float)num9) : ((Bounds)(ref val4)).center); GameObject val14 = new GameObject("Axe"); val14.transform.SetParent(_root.transform, false); GameObject val15 = new GameObject("Model"); val15.transform.SetParent(val14.transform, false); val15.transform.localRotation = val11; val15.transform.localScale = Vector3.one * num6; val15.transform.localPosition = -(val11 * val13) * num6; foreach (var item5 in list) { GameObject val16 = new GameObject(((Object)item5.Item1).name); val16.transform.SetParent(val15.transform, false); Transform transform = val16.transform; Matrix4x4 item2 = item5.Item3; transform.localPosition = Vector4.op_Implicit(((Matrix4x4)(ref item2)).GetColumn(3)); Transform transform2 = val16.transform; item2 = item5.Item3; transform2.localRotation = ((Matrix4x4)(ref item2)).rotation; Transform transform3 = val16.transform; item2 = item5.Item3; transform3.localScale = ((Matrix4x4)(ref item2)).lossyScale; val16.AddComponent<MeshFilter>().sharedMesh = item5.Item1.sharedMesh; ((Renderer)val16.AddComponent<MeshRenderer>()).sharedMaterials = ((Renderer)item5.Item2).sharedMaterials; } _axe = val14.transform; return true; float Spread(bool top, Vector3 across) { //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_0022: 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_0057: 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) float num11 = float.MaxValue; float num12 = float.MinValue; foreach (Vector3 item6 in points) { float num13 = (Vector3.Dot(item6, axis) - low) / length; if (!(top ? (num13 < 0.78f) : (num13 > 0.22f))) { float num14 = Vector3.Dot(item6, across); num11 = Mathf.Min(num11, num14); num12 = Mathf.Max(num12, num14); } } if (!(num12 > num11)) { return 0f; } return num12 - num11; } } } internal static class Line { public static Vector3 Anchor(Post post) { //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_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) return ((Component)post).transform.position + ((Component)post).transform.up * 4.2f; } public static float Sag(float length) { return Mathf.Clamp(length * 0.015f, 0.15f, 1.6f); } public static Vector3 Point(Vector3 a, Vector3 b, float t) { //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_0003: 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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0035: 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) return Vector3.Lerp(a, b, t) + Vector3.down * Sag(Vector3.Distance(a, b)) * 4f * t * (1f - t); } public static string Clearance(Vector3 a, Vector3 b, Post ignoreA, Post ignoreB) { //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_004f: 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_007c: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_015d: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) float num = Vector3.Distance(a, b); float value = Plugin.Hang.Value; int mask = LayerMask.GetMask(new string[6] { "Default", "static_solid", "terrain", "piece", "Default_small", "vehicle" }); Vector3 val = a; int num2 = Mathf.Clamp(Mathf.RoundToInt(num / 15f), 48, 1200); float num5 = default(float); RaycastHit val3 = default(RaycastHit); for (int i = 1; i <= num2; i++) { float num3 = (float)i / (float)num2; Vector3 val2 = Point(a, b, num3); float num4 = ((WorldGenerator.instance != null) ? WorldGenerator.instance.GetHeight(val2.x, val2.z) : float.MinValue); try { if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.IsZoneLoaded(val2) && ZoneSystem.instance.GetSolidHeight(val2, ref num5, 1000) && !float.IsNaN(num5) && Mathf.Abs(num5 - num4) < 40f) { num4 = Mathf.Max(num4, num5); } } catch (Exception) { } if (num3 > 0.06f && num3 < 0.94f && num4 > float.MinValue && val2.y - value < num4 + 0.25f) { return Translations.T("ziplines_drag", (num * num3).ToString("0")); } if (Physics.Linecast(val, val2, ref val3, mask, (QueryTriggerInteraction)1)) { Post componentInParent = ((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent<Post>(); if (componentInParent == null || (!((Object)(object)componentInParent == (Object)(object)ignoreA) && !((Object)(object)componentInParent == (Object)(object)ignoreB))) { return Translations.T("ziplines_in_way", (num * num3).ToString("0"), Describe(((RaycastHit)(ref val3)).collider)); } } val = val2; } return null; } private static string Describe(Collider c) { Piece componentInParent = ((Component)c).GetComponentInParent<Piece>(); if ((Object)(object)componentInParent != (Object)null) { return Localization.instance.Localize(componentInParent.m_name); } if (!((Object)(object)((Component)c).GetComponentInParent<TreeBase>() != (Object)null) && !((Object)(object)((Component)c).GetComponentInParent<TreeLog>() != (Object)null)) { if (!((Object)c).name.ToLowerInvariant().Contains("terrain")) { return Translations.T("ziplines_rock_or_tree"); } return Translations.T("ziplines_the_ground"); } return Translations.T("ziplines_a_tree"); } } [BepInPlugin("com.quad.ziplines", "Ziplines", "0.3.2")] public class Plugin : BaseUnityPlugin { public const string Guid = "com.quad.ziplines"; public const string OldGuid = "com.dhack.ziplines"; public const string Name = "Ziplines"; public const string Version = "0.3.2"; internal static Plugin Instance; internal static ManualLogSource Log; internal static ServerSettings Synced; internal static ConfigEntry<float> MaxLength; internal static ConfigEntry<float> MinSlope; internal static ConfigEntry<float> TopSpeed; internal static ConfigEntry<float> MinSpeed; internal static ConfigEntry<float> Hang; internal static ConfigEntry<float> SpeedScale; internal static ConfigEntry<float> WindVolume; internal static ConfigEntry<bool> Wind; internal static ConfigEntry<bool> WideView; internal static ConfigEntry<bool> LongFaster; internal static ConfigEntry<bool> NeedAxe; private Harmony _harmony; private void Awake() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Expected O, but got Unknown //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Expected O, but got Unknown //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Expected O, but got Unknown //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Expected O, but got Unknown //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Expected O, but got Unknown Migration.FromOldGuid((BaseUnityPlugin)(object)this, "com.dhack.ziplines"); Translations.Load((BaseUnityPlugin)(object)this); Instance = this; Log = ((BaseUnityPlugin)this).Logger; Synced = new ServerSettings("com.quad.ziplines", ((BaseUnityPlugin)this).Config, ((BaseUnityPlugin)this).Logger); MaxLength = Synced.Add<float>(((BaseUnityPlugin)this).Config.Bind<float>("Lines", "MaxLength", 12000f, new ConfigDescription("The longest a zipline can be (metres). A line remembers where its other end is, so the far post does not have to be loaded: the world around you loads as you ride. In multiplayer the server's value applies.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(15f, 20000f), Array.Empty<object>()))); MinSlope = Synced.Add<float>(((BaseUnityPlugin)this).Config.Bind<float>("Lines", "MinSlope", 0.005f, new ConfigDescription("How much a line must fall to be ridden, as a part of its length (0.005 is 5 m in every 1000). A line only runs downhill, from its higher post to its lower. In multiplayer the server's value applies.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.001f, 0.1f), Array.Empty<object>()))); LongFaster = Synced.Add<bool>(((BaseUnityPlugin)this).Config.Bind<bool>("Riding", "LongLinesFaster", true, "The longer the line, the faster you go (up to eight times), so a line of kilometres takes minutes, not an hour. You slow down for the last stretch either way. In multiplayer the server's value applies.")); TopSpeed = Synced.Add<float>(((BaseUnityPlugin)this).Config.Bind<float>("Riding", "TopSpeed", 24f, new ConfigDescription("How fast you go downhill at the most (metres per second). In multiplayer the server's value applies.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(6f, 40f), Array.Empty<object>()))); MinSpeed = Synced.Add<float>(((BaseUnityPlugin)this).Config.Bind<float>("Riding", "MinSpeed", 5f, new ConfigDescription("How fast you go on the flat or uphill at the least (metres per second). In multiplayer the server's value applies.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 15f), Array.Empty<object>()))); Hang = ((BaseUnityPlugin)this).Config.Bind<float>("Riding", "HangBelowRope", 2.5f, new ConfigDescription("How far below the rope your feet hang (metres): your arms reach up to the handle, so this is about your height plus a little.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1.5f, 3.5f), Array.Empty<object>())); NeedAxe = Synced.Add<bool>(((BaseUnityPlugin)this).Config.Bind<bool>("Riding", "NeedAnAxe", true, "You hook an axe over the rope and hang from its handle, so you need one with you to ride. Off, you hang from a wooden triangle instead. In multiplayer the server's value applies.")); SpeedScale = Synced.Add<float>(((BaseUnityPlugin)this).Config.Bind<float>("Riding", "SpeedPercent", 50f, new ConfigDescription("How fast the whole ride is, as a percent of the standard speed (50 is half as fast, 200 twice). In multiplayer the server's value applies.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 300f), Array.Empty<object>()))); WindVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Riding", "WindVolume", 0.12f, new ConfigDescription("How loud the wind is at full speed (0 to 1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); WideView = ((BaseUnityPlugin)this).Config.Bind<bool>("Riding", "WideView", true, "The view widens as you speed up, for the feel of it."); Wind = ((BaseUnityPlugin)this).Config.Bind<bool>("Riding", "WindSound", true, "The sound of the wind, rising with your speed."); _harmony = new Harmony("com.quad.ziplines"); _harmony.PatchAll(typeof(Plugin).Assembly); Things.Register(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Ziplines 0.3.2 loaded"); ((MonoBehaviour)this).StartCoroutine(OtherZiplines()); } private IEnumerator OtherZiplines() { yield return null; yield return null; if (Chainloader.PluginInfos.ContainsKey("anwo.Ziplines")) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Einherjer's Ziplines (anwo.Ziplines) is installed too: it's a different mod with the same name. Both work, with their own posts and ropes; keep one if you only want one kind of zipline."); } } private void Update() { Synced?.Update(); Post.Network(); Ride.Tick(); Tools.Update(); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } Ride.End("The ziplines were reloaded."); Tools.Unregister(); Post.Unnetwork(); Post.ForgetAll(); Things.Unregister(); Synced?.Dispose(); Translations.Unload(); if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } [HarmonyPatch(typeof(ZNetScene), "Awake")] internal static class ZNetScene_Awake { private static void Postfix() { Things.Register(); } } [HarmonyPatch(typeof(ObjectDB), "Awake")] internal static class ObjectDB_Awake { private static void Postfix() { Things.Register(); } } [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] internal static class ObjectDB_CopyOtherDB { private static void Postfix() { Things.Register(); } } internal static class Pose { private static Transform _root; private static Transform _lArm; private static Transform _lFore; private static Transform _lHand; private static Transform _rArm; private static Transform _rFore; private static Transform _rHand; private static Transform _lUp; private static Transform _lLeg; private static Transform _lFoot; private static Transform _rUp; private static Transform _rLeg; private static Transform _rFoot; private static readonly string[] Fingers = new string[4] { "Index", "Middle", "Ring", "Pinky" }; public static bool Ready { get { if ((Object)(object)_lHand != (Object)null) { return (Object)(object)_rHand != (Object)null; } return false; } } public static void Begin(Player player) { _root = ((Component)player).transform.Find("Visual/Armature"); if (!((Object)(object)_root == (Object)null)) { _lArm = Find("LeftArm"); _lFore = Find("LeftForeArm"); _lHand = Find("LeftHand"); _rArm = Find("RightArm"); _rFore = Find("RightForeArm"); _rHand = Find("RightHand"); _lUp = Find("LeftUpLeg"); _lLeg = Find("LeftLeg"); _lFoot = Find("LeftFoot"); _rUp = Find("RightUpLeg"); _rLeg = Find("RightLeg"); _rFoot = Find("RightFoot"); } } public static void End() { _lHand = (_rHand = null); _root = null; } private static Transform Find(string name) { return Search(_root, name); } private static Transform Search(Transform t, string name) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown if (((Object)t).name == name) { return t; } foreach (Transform item in t) { Transform t2 = item; Transform val = Search(t2, name); if ((Object)(object)val != (Object)null) { return val; } } return null; } private static void Aim(Transform bone, Transform child, Vector3 direction) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0051: 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) if (!((Object)(object)bone == (Object)null) && !((Object)(object)child == (Object)null)) { Vector3 val = child.position - bone.position; if (!(((Vector3)(ref val)).sqrMagnitude < 1E-06f) && !(((Vector3)(ref direction)).sqrMagnitude < 1E-06f)) { bone.rotation = Quaternion.FromToRotation(((Vector3)(ref val)).normalized, ((Vector3)(ref direction)).normalized) * bone.rotation; } } } public static void Apply(Transform carriage, Vector3 centre, Vector3 axis, bool vertical) { //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_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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_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_002b: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0053: 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_006b: 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_0076: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: 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_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: 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_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: 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_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_021c: 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_0222: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) if (Ready) { Vector3 up = Vector3.up; Vector3 val = Vector3.ProjectOnPlane(carriage.forward, up); Vector3 normalized = ((Vector3)(ref val)).normalized; Vector3 val2 = Vector3.Cross(up, normalized); Vector3 target = (vertical ? (centre + up * 0.13f) : (centre - val2 * 0.2f)); Vector3 target2 = (vertical ? (centre - up * 0.09f) : (centre + val2 * 0.2f)); Reach(_lArm, _lFore, _lHand, target, -val2 * 0.8f - up * 0.5f + normalized * 0.2f); Reach(_rArm, _rFore, _rHand, target2, val2 * 0.8f - up * 0.5f + normalized * 0.2f); Wrap(_lHand, "Left", centre, axis, -1f); Wrap(_rHand, "Right", centre, axis, 1f); float num = Mathf.Sin(Time.time * 2.3f) * 0.22f + Mathf.Sin(Time.time * 4.1f) * 0.06f; Aim(_lUp, _lLeg, -up + normalized * (0.26f + num * 0.6f) - val2 * 0.04f); Aim(_lLeg, _lFoot, -up - normalized * (0.3f - num) - val2 * 0.02f); Aim(_rUp, _rLeg, -up + normalized * (0.26f - num * 0.6f) + val2 * 0.04f); Aim(_rLeg, _rFoot, -up - normalized * (0.3f + num) + val2 * 0.02f); } } private static void Reach(Transform arm, Transform fore, Transform hand, Vector3 target, Vector3 pole) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0036: 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_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_0054: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_00dd: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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_0102: 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_010b: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)arm == (Object)null) && !((Object)(object)fore == (Object)null) && !((Object)(object)hand == (Object)null)) { Vector3 position = arm.position; float num = Vector3.Distance(arm.position, fore.position); float num2 = Vector3.Distance(fore.position, hand.position) + 0.03f; Vector3 val = target - position; float num3 = Mathf.Clamp(((Vector3)(ref val)).magnitude, 0.08f, num + num2 - 0.003f); Vector3 normalized = ((Vector3)(ref val)).normalized; float num4 = (num * num - num2 * num2 + num3 * num3) / (2f * num3); float num5 = Mathf.Sqrt(Mathf.Max(0f, num * num - num4 * num4)); Vector3 val2 = Vector3.ProjectOnPlane(pole, normalized); if (((Vector3)(ref val2)).sqrMagnitude < 1E-06f) { val2 = Vector3.down; } Vector3 val3 = position + normalized * num4 + ((Vector3)(ref val2)).normalized * num5; Aim(arm, fore, val3 - position); Aim(fore, hand, position + normalized * num3 - fore.position); } } private static void Wrap(Transform hand, string side, Vector3 centre, Vector3 axis, float sign) { //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_0055: 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) if (!((Object)(object)hand == (Object)null)) { string[] fingers = Fingers; foreach (string text in fingers) { Curl(hand, side + "Hand" + text, centre, axis, sign, new float[3] { 18f, 70f, 120f }); } Curl(hand, side + "HandThumb", centre, axis, 0f - sign, new float[3] { 20f, 50f, 80f }); } } private static void Curl(Transform hand, string name, Vector3 centre, Vector3 axis, float sign, float[] angles) { //IL_0064: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0082: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) Transform val = Search(hand, name + "1"); Transform val2 = Search(hand, name + "2"); Transform val3 = Search(hand, name + "3"); Transform val4 = Search(hand, name + "3_end"); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null) { return; } Vector3 val5 = centre + axis * Vector3.Dot(val.position - centre, axis); Vector3 val6 = val5 - val.position; if (!(((Vector3)(ref val6)).sqrMagnitude < 1E-06f)) { ((Vector3)(ref val6)).Normalize(); Aim(val, val2, Quaternion.AngleAxis(angles[0] * sign, axis) * val6); Aim(val2, val3, Quaternion.AngleAxis(angles[1] * sign, axis) * val6); if ((Object)(object)val4 != (Object)null) { Aim(val3, val4, Quaternion.AngleAxis(angles[2] * sign, axis) * val6); } } } } internal class Post : MonoBehaviour, Hoverable, Interactable { private const string IdKey = "dhz_id"; private const string ToKey = "dhz_to"; private const string ToPosKey = "dhz_tp"; private static readonly List<Post> All = new List<Post>(); private static ZDOID _pendingZdo = ZDOID.None; private static long _pendingId; private static Vector3 _pendingAnchor; private static float _pendingAt; private ZNetView _view; private LineRenderer _rope; private float _next; private long _ropeTo; private Vector3 _ropeA; private Vector3 _ropeB; private static Material _ropeMaterial; private const string RpcLink = "Ziplines_LinkFar"; private const string RpcFree = "Ziplines_FreeFar"; private const string RpcRefused = "Ziplines_LinkRefused"; private static ZRoutedRpc _registeredOn; public long Id { get { ZDO obj = Zdo(); if (obj == null) { return 0L; } return obj.GetLong("dhz_id", 0L); } } public long ToId { get { ZDO obj = Zdo(); if (obj == null) { return 0L; } return obj.GetLong("dhz_to", 0L); } } public Post Partner { get { long to = ToId; if (to != 0L) { return All.FirstOrDefault((Post p) => (Object)(object)p != (Object)null && (Object)(object)p != (Object)(object)this && p.Id == to); } return null; } } public Vector3 PartnerAnchor { get { //IL_0011: 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_0021: Unknown result type (might be due to invalid IL or missing references) Post partner = Partner; if ((Object)(object)partner != (Object)null) { return Line.Anchor(partner); } ZDO obj = Zdo(); if (obj == null) { return Vector3.zero; } return obj.GetVec3("dhz_tp", Vector3.zero); } } public bool HasLine { get { //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) if (ToId != 0L) { return PartnerAnchor != Vector3.zero; } return false; } } private static bool IsServer { get { if ((Object)(object)ZNet.instance != (Object)null) { return ZNet.instance.IsServer(); } return false; } } public static IEnumerable<Post> Loaded() { return All.Where((Post p) => (Object)(object)p != (Object)null); } public static void ForgetAll() { //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) _pendingZdo = ZDOID.None; _pendingId = 0L; foreach (Post item in All.ToList()) { if ((Object)(object)item != (Object)null) { item.DropRope(); } } } private void Awake() { _view = ((Component)this).GetComponent<ZNetView>(); All.Add(this); } private void OnDestroy() { All.Remove(this); DropRope(); } private ZDO Zdo() { if (!((Object)(object)_view != (Object)null) || !_view.IsValid()) { return null; } return _view.GetZDO(); } private void Update() { if (Time.time < _next) { return; } _next = Time.time + 0.5f; ZDO val = Zdo(); if (val != null) { if (val.GetLong("dhz_id", 0L) == 0L && _view.IsOwner()) { val.Set("dhz_id", NewId()); } UpdateRope(); } } internal static long EnsureId(ZDO zdo) { long num = zdo.GetLong("dhz_id", 0L); if (num == 0L) { num = NewId(); zdo.Set("dhz_id", num); } return num; } internal void ClearLine() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_view != (Object)null && !_view.IsOwner()) { _view.ClaimOwnership(); } ZDO obj = Zdo(); if (obj != null) { obj.Set("dhz_to", 0L); } ZDO obj2 = Zdo(); if (obj2 != null) { obj2.Set("dhz_tp", Vector3.zero); } } private static long NewId() { return BitConverter.ToInt64(Guid.NewGuid().ToByteArray(), 0) & 0x7FFFFFFFFFFFFFFFL; } private static ZDO PendingZdo() { //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_0031: Unknown result type (might be due to invalid IL or missing references) if (_pendingZdo == ZDOID.None || Time.time - _pendingAt > 21600f || ZDOMan.instance == null) { return null; } ZDO zDO = ZDOMan.instance.GetZDO(_pendingZdo); if (zDO == null || !zDO.IsValid() || zDO.GetLong("dhz_id", 0L) != _pendingId || zDO.GetLong("dhz_to", 0L) != 0L) { return null; } return zDO; } public string GetHoverName() { return Translations.T("ziplines_post"); } public float GetHoverOffset() { return 0f; } public string GetHoverText() { //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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_02b8: Unknown result type (might be due to invalid IL or missing references) string text = "[<color=yellow><b>$KEY_Use</b></color>]"; string text2 = "[<color=yellow><b>$KEY_AltPlace + $KEY_Use</b></color>]"; string text5; if (HasLine) { Vector3 partnerAnchor = PartnerAnchor; float num = Vector3.Distance(Line.Anchor(this), partnerAnchor); float num2 = Line.Anchor(this).y - partnerAnchor.y; string text3 = ((num >= 1000f) ? Translations.T("ziplines_km", (num / 1000f).ToString("0.0")) : Translations.T("ziplines_metres", num.ToString("0"))); string text4 = "\n" + text2 + " " + Translations.T("ziplines_hover_take_down"); text5 = ((num2 >= 0.5f) ? (Translations.T("ziplines_post") + "\n" + text + " " + Translations.T("ziplines_hover_ride", text3, num2.ToString("0")) + text4) : (Translations.T("ziplines_post") + "\n" + Translations.T("ziplines_hover_bottom", text3, (0f - num2).ToString("0")) + text4)); } else if (ToId != 0L) { text5 = Translations.T("ziplines_post") + "\n" + Translations.T("ziplines_hover_lost") + "\n" + text2 + " " + Translations.T("ziplines_hover_take_down"); } else { ZDO val = PendingZdo(); text5 = ((val == null) ? (Translations.T("ziplines_post") + "\n" + text + " " + Translations.T("ziplines_hover_start")) : ((val != Zdo()) ? (Translations.T("ziplines_post") + "\n" + text + " " + Translations.T("ziplines_hover_run", Vector3.Distance(_pendingAnchor, Line.Anchor(this)).ToString("0"))) : (Translations.T("ziplines_post") + "\n" + text + " " + Translations.T("ziplines_hover_cancel")))); } return Localization.instance.Localize(text5); } public bool UseItem(Humanoid user, ItemData item) { return false; } public bool Interact(Humanoid user, bool hold, bool alt) { //IL_007a: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: 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_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) Plugin.Log.LogInfo((object)$"Interact: hold {hold}, alt {alt}, user {((user != null) ? ((Object)user).name : null)}, hasLine {HasLine}"); if (!hold) { Player val = (Player)(object)((user is Player) ? user : null); if (val != null && !((Object)(object)val != (Object)(object)Player.m_localPlayer)) { if (alt) { TakeDown(val); return true; } if (HasLine) { if (Line.Anchor(this).y - PartnerAnchor.y < 0.5f) { ((Character)val).Message((MessageType)2, Translations.T("ziplines_downhill_only"), 0, (Sprite)null, false); return true; } Ride.Start(val, this, PartnerAnchor, Partner); return true; } if (ToId != 0L) { ((Character)val).Message((MessageType)2, Translations.T("ziplines_lost_end"), 0, (Sprite)null, false); return true; } ZDO val2 = Zdo(); if (val2 == null) { return true; } if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false)) { ((Character)val).Message((MessageType)2, "$piece_noaccess", 0, (Sprite)null, false); return true; } ZDO val3 = PendingZdo(); if (val3 == null) { if (val2.GetLong("dhz_id", 0L) == 0L) { ((Character)val).Message((MessageType)2, Translations.T("ziplines_not_ready"), 0, (Sprite)null, false); return true; } _pendingZdo = val2.m_uid; _pendingId = val2.GetLong("dhz_id", 0L); _pendingAnchor = Line.Anchor(this); _pendingAt = Time.time; ((Character)val).Message((MessageType)2, Translations.T("ziplines_started"), 0, (Sprite)null, false); return true; } if (val3 == val2) { _pendingZdo = ZDOID.None; ((Character)val).Message((MessageType)2, Translations.T("ziplines_cancelled"), 0, (Sprite)null, false); return true; } if (Join(val, val3, _pendingId, _pendingAnchor, this)) { _pendingZdo = ZDOID.None; } return true; } } return false; } internal static bool Join(Player player, ZDO farZdo, long farId, Vector3 farAnchor, Post here) { //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_00ce: 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_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_015a: 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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015d: 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_016e: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016f: 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_0173: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Line.Anchor(here); float num = Vector3.Distance(val, farAnchor); if (here.ToId != 0L) { ((Character)player).Message((MessageType)2, Translations.T("ziplines_has_line"), 0, (Sprite)null, false); return false; } if (num < 8f) { ((Character)player).Message((MessageType)2, Translations.T("ziplines_too_close"), 0, (Sprite)null, false); return false; } if (num > Plugin.MaxLength.Value) { ((Character)player).Message((MessageType)2, Translations.T("ziplines_too_far", Plugin.MaxLength.Value.ToString("0"), num.ToString("0")), 0, (Sprite)null, false); return false; } Post post = All.FirstOrDefault((Post p) => (Object)(object)p != (Object)null && p.Id == farId); float num2 = Mathf.Abs(farAnchor.y - val.y); float num3 = Mathf.Max(2f, num * Plugin.MinSlope.Value); if (num2 < num3) { ((Character)player).Message((MessageType)2, Translations.T("ziplines_too_flat", num3.ToString("0"), num.ToString("0"), num2.ToString("0")), 0, (Sprite)null, false); return false; } Vector3 a = ((farAnchor.y >= val.y) ? farAnchor : val); Vector3 b = ((farAnchor.y >= val.y) ? val : farAnchor); string text = Line.Clearance(a, b, post, here); if (text != null) { ((Character)player).Message((MessageType)2, text, 0, (Sprite)null, false); return false; } if (!here._view.IsOwner()) { here._view.ClaimOwnership(); } ZDO val2 = here.Zdo(); long num4 = val2.GetLong("dhz_id", 0L); if (num4 == 0L) { num4 = NewId(); val2.Set("dhz_id", num4); } val2.Set("dhz_to", farId); val2.Set("dhz_tp", farAnchor); if ((Object)(object)post != (Object)null) { if (!post._view.IsOwner()) { post._view.ClaimOwnership(); } farZdo.Set("dhz_to", num4); farZdo.Set("dhz_tp", val); } else if (IsServer) { WriteFar(farZdo, num4, val); } else { ZRoutedRpc.instance.InvokeRoutedRPC("Ziplines_LinkFar", new object[3] { farId, num4, val }); } ((Character)player).Message((MessageType)2, Translations.T("ziplines_joined", num.ToString("0")), 0, (Sprite)null, false); return true; } internal static bool Join(Player player, Post a, Post b) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) ZDO val = a.Zdo(); ZDO val2 = b.Zdo(); if (val == null || val2 == null || a.Id == 0L || b.Id == 0L) { ((Character)player).Message((MessageType)2, Translations.T("ziplines_post_not_ready"), 0, (Sprite)null, false); return false; } return Join(player, val, a.Id, Line.Anchor(a), b); } private void TakeDown(Player player) { //IL_001b: 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_00bd: Unknown result type (might be due to invalid IL or missing references) Post partner = Partner; long toId = ToId; long id = Id; if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false) || ((Object)(object)partner != (Object)null && !PrivateArea.CheckAccess(((Component)partner).transform.position, 0f, true, false))) { ((Character)player).Message((MessageType)2, "$piece_noaccess", 0, (Sprite)null, false); return; } Post[] array = new Post[2] { this, partner }; foreach (Post post in array) { if (!((Object)(object)post == (Object)null)) { if (!post._view.IsOwner()) { post._view.ClaimOwnership(); } post.Zdo().Set("dhz_to", 0L); post.Zdo().Set("dhz_tp", Vector3.zero); } } if ((Object)(object)partner == (Object)null && toId != 0L && ZDOMan.instance != null) { if (IsServer) { Free(toId, id); } else { ZRoutedRpc.instance.InvokeRoutedRPC("Ziplines_FreeFar", new object[2] { toId, id }); } } ((Character)player).Message((MessageType)2, Translations.T("ziplines_down"), 0, (Sprite)null, false); } internal static IEnumerable<ZDO> FarPosts(long id) { List<ZDO> list = new List<ZDO>(); int num = 0; int hash = StringExtensionMethods.GetStableHashCode("dh_zip_post"); for (int i = 0; i < 2000; i++) { if (ZDOMan.instance.GetAllZDOsWithPrefabIterative("dh_zip_post", list, ref num)) { break; } } return list.Where((ZDO z) => z != null && z.GetLong("dhz_id", 0L) == id && z.GetPrefab() == hash); } public static void Network() { ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != _registeredOn) { Unnetwork(); if (instance != null) { Forget(instance); instance.Register<long, long, Vector3>("Ziplines_LinkFar", (Action<long, long, long, Vector3>)OnLink); instance.Register<long, long>("Ziplines_FreeFar", (Action<long, long, long>)OnFree); instance.Register<long, long>("Ziplines_LinkRefused", (Action<long, long, long>)OnRefused); _registeredOn = instance; } } } public static void Unnetwork() { if (_registeredOn != null) { Forget(_registeredOn); } _registeredOn = null; } private static void Forget(ZRoutedRpc rpc) { if (AccessTools.Field(typeof(ZRoutedRpc), "m_functions")?.GetValue(rpc) is IDictionary dictionary) { string[] array = new string[3] { "Ziplines_LinkFar", "Ziplines_FreeFar", "Ziplines_LinkRefused" }; foreach (string text in array) { dictionary.Remove(StringExtensionMethods.GetStableHashCode(text)); } } } private static void WriteFar(ZDO zdo, long to, Vector3 toAnchor) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (!zdo.HasOwner()) { zdo.SetOwner(ZDOMan.GetSessionID()); } zdo.Set("dhz_to", to); zdo.Set("dhz_tp", toAnchor); } private static void Free(long id, long linkedTo) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) foreach (ZDO item in FarPosts(id).ToList()) { if (item.GetLong("dhz_to", 0L) == linkedTo) { WriteFar(item, 0L, Vector3.zero); } } } private static void OnLink(long sender, long farId, long hereId, Vector3 hereAnchor) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (IsServer && ZDOMan.instance != null) { ZDO val = FarPosts(farId).FirstOrDefault(); long num = ((val != null) ? val.GetLong("dhz_to", 0L) : (-1)); if (val != null && (num == 0L || num == hereId)) { WriteFar(val, hereId, hereAnchor); return; } Plugin.Log.LogInfo((object)string.Format("A line to post {0} was refused: {1}", farId, (val == null) ? "no such post" : "it has another line")); ZRoutedRpc.instance.InvokeRoutedRPC(sender, "Ziplines_LinkRefused", new object[2] { hereId, farId }); } } private static void OnFree(long sender, long farId, long hereId) { if (IsServer && ZDOMan.instance != null) { Free(farId, hereId); } } private static void OnRefused(long sender, long hereId, long farId) { Post post = All.FirstOrDefault((Post p) => (Object)(object)p != (Object)null && p.Id == hereId); if (!((Object)(object)post == (Object)null) && post.ToId == farId) { post.ClearLine(); Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, Translations.T("ziplines_cancelled"), 0, (Sprite)null, false); } } } private void UpdateRope() { //IL_0035: 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_0041: 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_008c: Expected O, but got Unknown //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0133: 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_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015d: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) if (!HasLine) { DropRope(); return; } Post partner = Partner; if ((Object)(object)partner != (Object)null && Id > partner.Id) { DropRope(); return; } Vector3 val = Line.Anchor(this); Vector3 partnerAnchor = PartnerAnchor; if (!((Object)(object)_rope != (Object)null) || _ropeTo != ToId || !(_ropeA == val) || !(_ropeB == partnerAnchor)) { DropRope(); GameObject val2 = new GameObject("ZipRope"); val2.transform.SetParent(((Component)this).transform, false); _rope = val2.AddComponent<LineRenderer>(); _rope.useWorldSpace = true; _rope.widthMultiplier = 0.045f; _rope.numCapVertices = 3; ((Renderer)_rope).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)_rope).sharedMaterial = RopeMaterial(); int num = Mathf.Clamp(Mathf.RoundToInt(Vector3.Distance(val, partnerAnchor) / 4f), 28, 500); _rope.positionCount = num + 1; for (int i = 0; i <= num; i++) { _rope.SetPosition(i, Line.Point(val, partnerAnchor, (float)i / (float)num)); } _ropeTo = ToId; _ropeA = val; _ropeB = partnerAnchor; } } private void DropRope() { if ((Object)(object)_rope != (Object)null) { Object.Destroy((Object)(object)((Component)_rope).gameObject); } _rope = null; _ropeTo = 0L; } private static Material RopeMaterial() { //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown if ((Object)(object)_ropeMaterial != (Object)null) { return _ropeMaterial; } Material val = null; GameObject val2 = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab("Wood") : null); if ((Object)(object)val2 != (Object)null) { Renderer[] componentsInChildren = val2.GetComponentsInChildren<Renderer>(true); foreach (Renderer val3 in componentsInChildren) { val = val ?? ((IEnumerable<Material>)val3.sharedMaterials).FirstOrDefault((Func<Material, bool>)((Material m) => (Object)(object)m != (Object)null && ((Object)m).name == "wood_item")); } } if ((Object)(object)val == (Object)null) { Shader val4 = Shader.Find("Standard") ?? Shader.Find("Sprites/Default"); if ((Object)(object)val4 == (Object)null) { return null; } val = new Material(val4); } _ropeMaterial = new Material(val) { color = new Color(0.82f, 0.72f, 0.48f) }; if (_ropeMaterial.HasProperty("_MainTex")) { _ropeMaterial.mainTexture = null; } return _ropeMaterial; } } internal static class Ride { private static Player _rider; private static Transform _trolley; private static Vector3 _a; private static Vector3 _b; private static Vector3 _start; private static Vector3 _land; private static float _t; private static float _speed; private static float _length; private static float _phaseAt; private static float _boost; private static float _waitedForGround; private static int _phase; private static AudioSource _wind; private static AudioClip _windClip; private static AudioMixerGroup _mixer; public static Vector3 RopePoint; private static readonly FieldRef<Character, float> MaxAirAltitude = AccessTools.FieldRefAccess<Character, float>("m_maxAirAltitude"); public static bool Active => (Object)(object)_rider != (Object)null; public static float Speed => _speed; public static bool Riding(Player player) { if ((Object)(object)_rider != (Object)null && (Object)(object)player != (Object)null) { return (Object)(object)_rider == (Object)(object)player; } return false; } public static void Late() { //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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0036: 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_0041: 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_0055: 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_0068: 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_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) if (!((Object)(object)_rider == (Object)null) && !((Object)(object)_trolley == (Object)null)) { Vector3 val = Flat(_b - _a); Vector3 val2 = Vector3.Cross(Vector3.up, val); Vector3 val3 = RopePoint - Vector3.up * 0.42f; bool isAxe = Grip.IsAxe; Pose.Apply(_trolley, val3, isAxe ? Vector3.up : val2, isAxe); Grip.Update(_trolley, RopePoint, val3); } } public static void Start(Player player, Post from, Vector3 toAnchor, Post to) { //IL_0101: 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_010b: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027d: 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_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: 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_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) Plugin.Log.LogInfo((object)$"Ride asked for: active {Active}, dead {((Character)player).IsDead()}, attached {((Character)player).IsAttached()}, building {((Character)player).InPlaceMode()}, swimming {((Character)player).IsSwimming()}"); ItemData val = Grip.FindAxe(player); if (Plugin.NeedAxe.Value && val == null && !Active) { ((Character)player).Message((MessageType)2, Translations.T("ziplines_need_axe"), 0, (Sprite)null, false); return; } if (Active) { Plugin.Log.LogInfo((object)" already riding (a ride that did not end?)"); return; } if (((Character)player).IsDead() || ((Character)player).IsAttached() || ((Character)player).InPlaceMode() || ((Character)player).IsSwimming()) { ((Character)player).Message((MessageType)2, ((Character)player).InPlaceMode() ? Translations.T("ziplines_hammer_away") : Translations.T("ziplines_cannot_ride"), 0, (Sprite)null, false); return; } _a = Line.Anchor(from); _b = toAnchor; if (_a.y - _b.y < 0.5f) { ((Character)player).Message((MessageType)2, Translations.T("ziplines_downhill_only"), 0, (Sprite)null, false); return; } string text = Line.Clearance(_a, _b, from, to); if (text != null) { Plugin.Log.LogInfo((object)(" refused: " + text)); ((Character)player).Message((MessageType)2, text, 0, (Sprite)null, false); return; } Plugin.Log.LogInfo((object)$" riding {Vector3.Distance(_a, _b):0} m"); _length = Vector3.Distance(_a, _b); _boost = (Plugin.LongFaster.Value ? Mathf.Clamp(1f + _length / 300f, 1f, 8f) : 1f); _t = Mathf.Min(0.5f, 0.9f / _length); _speed = Plugin.MinSpeed.Value * 0.6f; _waitedForGround = 0f; _start = ((Component)player).transform.position; _phase = 0; _phaseAt = Time.time; _rider = player; _trolley = new GameObject("ZipCarriage").transform; _trolley.position = _start; _trolley.rotation = Quaternion.LookRotation(Flat(_b - _a)); ((Character)player).AttachStart(_trolley, (GameObject)null, true, false, false, "attach_mast", Vector3.zero, (Transform)null); Pose.Begin(player); Grip.Begin(player, Plugin.NeedAxe.Value ? val : null); RopePoint = Line.Point(_a, _b, _t); StartWind(); } private static Vector3 Flat(Vector3 v) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) v.y = 0f; if (!(((Vector3)(ref v)).sqrMagnitude < 0.0001f)) { return ((Vector3)(ref v)).normalized; } return Vector3.forward; } private static Vector3 Carriage(float t) { //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_0010: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_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) RopePoint = Line.Point(_a, _b, Mathf.Clamp01(t)); return RopePoint + Vector3.down * Plugin.Hang.Value - Flat(_b - _a) * 0.24f; } public static void Tick() { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_009e: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: 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_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_030a: 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_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0361: 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_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_rider == (Object)null) { return; } if (((Character)_rider).IsDead() || !((Character)_rider).IsAttached() || (Object)(object)_trolley == (Object)null) { Finish(); return; } if ((ZInput.GetButtonDown("Jump") || ZInput.GetButtonDown("JoyJump")) && _phase == 1) { ((Character)_rider).AttachStop(); Finish(); return; } float deltaTime = Time.deltaTime; _trolley.rotation = Quaternion.Slerp(_trolley.rotation, Quaternion.LookRotation(Flat(_b - _a)), deltaTime * 6f); switch (_phase) { case 0: { float num7 = Mathf.SmoothStep(0f, 1f, (Time.time - _phaseAt) / 0.7f); _trolley.position = Vector3.Lerp(_start, Carriage(_t), num7); if (num7 >= 1f) { _phase = 1; } break; } case 1: { float num3 = (_a.y - _b.y) / _length; float num4 = Plugin.SpeedScale.Value / 100f; float num5 = Mathf.Clamp(Plugin.MinSpeed.Value + 55f * num3, Plugin.MinSpeed.Value, Plugin.TopSpeed.Value) * _boost * num4; float num6 = (1f - _t) * _length; if (num6 < 250f) { num5 = Mathf.Min(num5, Mathf.Lerp(Plugin.MinSpeed.Value * 1.2f * num4, num5, Mathf.Clamp01((num6 - 20f) / 230f))); } _speed += (num5 - _speed) * Mathf.Min(1f, deltaTime * ((_speed > num5) ? 0.9f : 1.2f)); _t += _speed * deltaTime / _length; _trolley.position = Carriage(_t); if (_t >= 1f - 1.2f / _length) { _phase = 2; _phaseAt = Time.time; _land = _trolley.position; } break; } default: { Vector3 val = _b + Flat(_b - _a) * 1.5f; float num = GroundAt(val, float.NaN); if (float.IsNaN(num)) { _waitedForGround += deltaTime; if (_waitedForGround < 6f) { _phaseAt = Time.time; _trolley.position = _land; break; } num = _b.y - 4.2f; } Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(val.x, num + 0.05f, val.z); float num2 = Mathf.SmoothStep(0f, 1f, (Time.time - _phaseAt) / 0.9f); _speed = Mathf.Lerp(_speed, 0f, deltaTime * 2.5f); _trolley.position = Vector3.Lerp(_land, val2, num2); if (num2 >= 1f) { ((Character)_rider).AttachStop(); Finish(); } break; } } UpdateWind(); } private static float GroundAt(Vector3 at, float fallback, float above = 6f, float reach = 80f) { //IL_003a: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0091: Unknown result type (might be due to invalid IL or missing references) int mask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "terrain", "piece", "Default_small" }); float num = float.MinValue; RaycastHit[] array = Physics.RaycastAll(at + Vector3.up * above, Vector3.down, reach, mask, (QueryTriggerInteraction)1); for (int i = 0; i < array.Length; i++) { RaycastHit val = array[i]; if (!((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<Post>() != (Object)null) && !((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<Character>() != (Object)null)) { num = Mathf.Max(num, ((RaycastHit)(ref val)).point.y); } } if (!(num > float.MinValue)) { return fallback; } return num; } public static void End(string why) { //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_0030: 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 ((Object)(object)_rider != (Object)null && ((Character)_rider).IsAttached()) { bool groundHere; Vector3 val = SafeSpot(out groundHere); ((Character)_rider).AttachStop(); SetDown(_rider, val, groundHere); Plugin.Log.LogInfo((object)$"Ride ended ({why}): set down at {val}"); } Finish(); } public static Vector3 SafeSpot(out bool groundHere) { //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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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_00bd: 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_0078: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to i