Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of Zipline v1.0.7
Mods/WoodStudios.Zipline.dll
Decompiled an hour 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.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.Json; using FybCommon; using HarmonyLib; using HoldTheFort; using Il2CppFishNet; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppScheduleOne; using Il2CppScheduleOne.AvatarFramework; using Il2CppScheduleOne.AvatarFramework.Animation; using Il2CppScheduleOne.Building; using Il2CppScheduleOne.Core.Items.Framework; using Il2CppScheduleOne.DevUtilities; using Il2CppScheduleOne.Equipping; using Il2CppScheduleOne.Instancing; using Il2CppScheduleOne.ItemFramework; using Il2CppScheduleOne.Map; using Il2CppScheduleOne.NPCs; using Il2CppScheduleOne.Networking; using Il2CppScheduleOne.Persistence; using Il2CppScheduleOne.PlayerScripts; using Il2CppScheduleOne.Property; using Il2CppScheduleOne.Storage; using Il2CppScheduleOne.Tiles; using Il2CppScheduleOne.UI; using Il2CppScheduleOne.UI.Shop; using Il2CppScheduleOne.Vehicles; using Il2CppScheduleOne.Weather; using Il2CppSteamworks; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppSystem.Reflection; using MelonLoader; using MelonLoader.Preferences; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using S1API.Items; using S1API.Items.Storable; using S1API.Lifecycle; using S1API.Rendering; using S1API.Shops; using UnityEngine; using UnityEngine.AI; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; using UnityEngine.Rendering.Universal; using UnityEngine.UI; using WoodKit; using Zipline; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(ZiplineCore), "Zipline", "1.0.7", "Wood Studios", null)] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: MelonOptionalDependencies(new string[] { "HoldTheFort" })] [assembly: AssemblyCompany("WoodStudios.Zipline")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("WoodStudios.Zipline")] [assembly: AssemblyTitle("WoodStudios.Zipline")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Zipline { internal static class Lines { private sealed class Line { public Placement.Placed P; public Vector3 BaseA; public Vector3 BaseB; public Vector3 TopA; public Vector3 TopB; public float HeightA; public float HeightB; public float Sag; public Transform PoleA; public Transform PoleB; } private static readonly Dictionary<Placement.Placed, Line> All = new Dictionary<Placement.Placed, Line>(); private static Vector3? _start; private static GameObject _startPole; private static GameObject _ghostEnd; private static GameObject _ghostCable; private static bool _ghostValid; private static float _startedAt; private static float _cableAt; private static Vector3 _cableA; private static Vector3 _cableB; private static bool _riding; private static Line _line; private static bool _forward; private static float _t; private static float _duration; private static float _endedAt = -10f; public static bool Riding => _riding; public static bool Place(ItemSpec spec, Camera cam, Player player, out string hint) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0194: 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_022a: 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_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) hint = null; if (!Placement.Aim(cam, 10f, player, out var best) || ((RaycastHit)(ref best)).normal.y < 0.75f) { HideGhost(); hint = (_start.HasValue ? StartedHint("Aim at flat ground for the other end") : "Aim at flat ground for the first pole"); return true; } Vector3 point = ((RaycastHit)(ref best)).point; if (!_start.HasValue) { bool flag = Clear(point, player); ShowGhost(point, null, flag); hint = (flag ? "[Click] Place the first pole" : "No room for a pole here"); if (flag && GameInput.GetButtonDown((ButtonCode)0)) { SetStart(point); _startedAt = Time.unscaledTime; } return true; } Vector3 value = _start.Value; float num = Flat(value, point); string text = null; float ha = 6.5f; float hb = 4.5f; if (num < 8f) { text = $"Too close to the first pole (at least {8f:0} m)"; } else if (num > 300f) { text = $"Too far from the first pole ({num:0} m, at most {300f:0} m)"; } else if (!Clear(point, player)) { text = "No room for a pole here"; } else if (!Heights(value, point, player, out ha, out hb)) { text = "Something's in the way of the cable"; } ShowGhost(point, value, text == null, ha, hb); if (text != null) { hint = StartedHint(text); return true; } hint = StartedHint($"[Click] Place the other end ({num:0} m)"); if (GameInput.GetButtonDown((ButtonCode)0) && Time.unscaledTime - _startedAt > 0.4f && Placement.PlaceNow(spec, value, Quaternion.identity, (Vector3[])(object)new Vector3[2] { point, new Vector3(ha, hb, 0f) }) != null) { Instance log = Kit.Log; if (log != null) { log.Msg($"Zipline strung: {num:0} m, poles {ha:0.#} m and {hb:0.#} m."); } ClearStart(); FortifyApi.Notify("Zipline ready", $"{num:0} m line. Press {Core.ViewKey} at either pole to ride."); } return true; } private static string StartedHint(string s) { return s + " [Right Click] Start over"; } private static void SetStart(Vector3 at) { //IL_0005: 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) ClearStart(); _start = at; _startPole = Models.ZiplinePole(6.5f, null, collider: false); ((Object)_startPole).name = Kit.Prefix + "StartPole"; _startPole.transform.position = at; foreach (Collider componentsInChild in _startPole.GetComponentsInChildren<Collider>(true)) { Object.Destroy((Object)(object)componentsInChild); } Placement.SetLayer(_startPole.transform, 2); } private static void ClearStart() { _start = null; if ((Object)(object)_startPole != (Object)null) { Object.Destroy((Object)(object)_startPole); } _startPole = null; } private static void ShowGhost(Vector3 at, Vector3? from, bool valid, float ha = 6.5f, float hb = 4.5f) { //IL_00c2: 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_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_00e1: 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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: 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_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_ghostEnd == (Object)null) { _ghostEnd = Models.ZiplinePole(6.5f, null, collider: false); ((Object)_ghostEnd).name = Kit.Prefix + "GhostPole"; foreach (Collider componentsInChild in _ghostEnd.GetComponentsInChildren<Collider>(true)) { Object.Destroy((Object)(object)componentsInChild); } foreach (Light componentsInChild2 in _ghostEnd.GetComponentsInChildren<Light>(true)) { ((Behaviour)componentsInChild2).enabled = false; } Placement.SetLayer(_ghostEnd.transform, 2); _ghostValid = !valid; } _ghostEnd.transform.position = at; if (from.HasValue) { Vector3 val = from.Value - at; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude > 0.01f) { _ghostEnd.transform.rotation = Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up); } SetPoleHeight(_ghostEnd, hb); if ((Object)(object)_startPole != (Object)null) { SetPoleHeight(_startPole, ha); Vector3 val2 = at - from.Value; val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude > 0.01f) { _startPole.transform.rotation = Quaternion.LookRotation(((Vector3)(ref val2)).normalized, Vector3.up); } } UpdateGhostCable(Top(from.Value, at, ha), Top(at, from.Value, hb), valid); } else if ((Object)(object)_ghostCable != (Object)null) { _ghostCable.SetActive(false); } if (!_ghostEnd.activeSelf) { _ghostEnd.SetActive(true); } if (valid == _ghostValid) { return; } _ghostValid = valid; Material val3 = Ghost(valid); foreach (Renderer componentsInChild3 in _ghostEnd.GetComponentsInChildren<Renderer>(true)) { int num = Mathf.Max(1, ((Il2CppArrayBase<Material>)(object)componentsInChild3.sharedMaterials).Length); Il2CppReferenceArray<Material> val4 = new Il2CppReferenceArray<Material>((long)num); for (int i = 0; i < num; i++) { ((Il2CppArrayBase<Material>)(object)val4)[i] = val3; } componentsInChild3.sharedMaterials = val4; } } private static Material Ghost(bool valid) { //IL_0076: 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) Material val = null; try { BuildManager instance = NetworkSingleton<BuildManager>.Instance; if ((Object)(object)instance != (Object)null) { val = (valid ? instance.ghostMaterial_White : instance.ghostMaterial_Red); } } catch { } Material val2 = val; if (val2 == null) { if (!valid) { return Models.Mat("ghost_bad", new Color(1f, 0.3f, 0.3f)); } val2 = Models.Mat("ghost_ok", new Color(0.8f, 0.9f, 1f)); } return val2; } private static void UpdateGhostCable(Vector3 a, Vector3 b, bool valid) { //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_0013: 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_0082: 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_0089: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_ghostCable != (Object)null) { Vector3 val = a - _cableA; if (((Vector3)(ref val)).sqrMagnitude < 0.04f) { val = b - _cableB; if (((Vector3)(ref val)).sqrMagnitude < 0.04f && Time.unscaledTime - _cableAt < 0.5f) { if (!_ghostCable.activeSelf) { _ghostCable.SetActive(true); } return; } } } if ((Object)(object)_ghostCable != (Object)null) { Object.Destroy((Object)(object)_ghostCable); } _cableA = a; _cableB = b; _cableAt = Time.unscaledTime; _ghostCable = Models.Cable(a, b, Vector3.Distance(a, b) * 0.025f, null); ((Object)_ghostCable).name = Kit.Prefix + "GhostCable"; Material sharedMaterial = Ghost(valid); foreach (Renderer componentsInChild in _ghostCable.GetComponentsInChildren<Renderer>(true)) { componentsInChild.sharedMaterial = sharedMaterial; } Placement.SetLayer(_ghostCable.transform, 2); } private static void HideGhost() { if ((Object)(object)_ghostEnd != (Object)null && _ghostEnd.activeSelf) { _ghostEnd.SetActive(false); } if ((Object)(object)_ghostCable != (Object)null && _ghostCable.activeSelf) { _ghostCable.SetActive(false); } } private static void DestroyGhost() { if ((Object)(object)_ghostEnd != (Object)null) { Object.Destroy((Object)(object)_ghostEnd); } if ((Object)(object)_ghostCable != (Object)null) { Object.Destroy((Object)(object)_ghostCable); } _ghostEnd = (_ghostCable = null); } private static void SetPoleHeight(GameObject pole, float h) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) Vector3 localScale = pole.transform.localScale; float num = h / 6.5f; if (Mathf.Abs(localScale.y - num) > 0.001f) { pole.transform.localScale = new Vector3(1f, num, 1f); } } private static float Flat(Vector3 a, Vector3 b) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) a.y = (b.y = 0f); return Vector3.Distance(a, b); } private static Vector3 Top(Vector3 baseAt, Vector3 toward, float height) { //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_002b: 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_0030: 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_0032: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) Vector3 val = toward - baseAt; val.y = 0f; val = ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val)).normalized : Vector3.forward); return baseAt + Vector3.up * height + val * 0.55f; } private static Vector3 Point(Vector3 a, Vector3 b, float sag, 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_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) return Vector3.Lerp(a, b, t) + Vector3.down * (4f * sag * t * (1f - t)); } private static bool Heights(Vector3 a, Vector3 b, Player player, out float ha, out float hb) { //IL_0013: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) ha = 6.5f; hb = 4.5f; for (int i = 0; i < 11; i++) { if (CableClear(Top(a, b, ha), Top(b, a, hb), player)) { return true; } ha += 1.5f; hb += 1.5f; } return false; } private static bool CableClear(Vector3 a, Vector3 b, Player player) { //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_000e: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_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_0052: 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_005c: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) float sag = Vector3.Distance(a, b) * 0.025f; int num = Mathf.Clamp(Mathf.CeilToInt(Vector3.Distance(a, b) / 6f), 8, 60); for (int i = 0; i < num; i++) { Vector3 val = Point(a, b, sag, (float)i / (float)num) + Vector3.down * 2f; Vector3 val2 = Point(a, b, sag, (float)(i + 1) / (float)num) + Vector3.down * 2f - val; foreach (RaycastHit item in (Il2CppArrayBase<RaycastHit>)(object)Physics.RaycastAll(val, ((Vector3)(ref val2)).normalized, ((Vector3)(ref val2)).magnitude, -5, (QueryTriggerInteraction)1)) { RaycastHit current = item; if (!((Object)(object)((RaycastHit)(ref current)).collider == (Object)null) && !((RaycastHit)(ref current)).collider.isTrigger && !Placement.IsPropertyBounds(((RaycastHit)(ref current)).collider) && (!((Object)(object)player != (Object)null) || !((Component)((RaycastHit)(ref current)).collider).transform.IsChildOf(((Component)player).transform)) && !((Object)(object)((Component)((RaycastHit)(ref current)).collider).GetComponentInParent<NPC>() != (Object)null) && !((Object)(object)((Component)((RaycastHit)(ref current)).collider).GetComponentInParent<LandVehicle>() != (Object)null)) { return false; } } } return true; } private static bool Clear(Vector3 at, Player player) { //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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_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) Il2CppReferenceArray<Collider> val = Physics.OverlapBox(at + Vector3.up * 1.4f, new Vector3(0.35f, 1.2f, 0.35f), Quaternion.identity, -5, (QueryTriggerInteraction)1); for (int i = 0; i < ((Il2CppArrayBase<Collider>)(object)val).Length; i++) { Collider val2 = ((Il2CppArrayBase<Collider>)(object)val)[i]; if (!((Object)(object)val2 == (Object)null) && !val2.isTrigger && !Placement.IsPropertyBounds(val2) && !(((MemberInfo)((Object)val2).GetIl2CppType()).Name == "TerrainCollider") && (!((Object)(object)player != (Object)null) || !((Component)val2).transform.IsChildOf(((Component)player).transform))) { return false; } } return true; } public static void Build(Placement.Placed p) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_010c: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: 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_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: 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) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) if (p?.Spec?.Id != "zl_zipline_kit" || (Object)(object)p.Go == (Object)null || p.Extra == null || p.Extra.Length < 2) { return; } GameObject go = p.Go; Vector3 position = go.transform.position; go.transform.rotation = Quaternion.identity; for (int num = go.transform.childCount - 1; num >= 0; num--) { Object.Destroy((Object)(object)((Component)go.transform.GetChild(num)).gameObject); } foreach (Collider component in go.GetComponents<Collider>()) { Object.Destroy((Object)(object)component); } foreach (Light component2 in go.GetComponents<Light>()) { Object.Destroy((Object)(object)component2); } Vector3 val = p.Extra[0]; float num2 = ((p.Extra[1].x > 0f) ? p.Extra[1].x : 6.5f); float num3 = ((p.Extra[1].y > 0f) ? p.Extra[1].y : 4.5f); Line line = new Line { P = p, BaseA = position, BaseB = val, HeightA = num2, HeightB = num3 }; line.PoleA = Pole("PoleA", go.transform, position, val, num2); line.PoleB = Pole("PoleB", go.transform, val, position, num3); line.TopA = Top(position, val, num2); line.TopB = Top(val, position, num3); line.Sag = Vector3.Distance(line.TopA, line.TopB) * 0.025f; ((Object)Models.Cable(line.TopA, line.TopB, line.Sag, go.transform)).name = "Cable"; All[p] = line; } private static Transform Pole(string name, Transform parent, Vector3 at, Vector3 facing, float height) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_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_004d: 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_0052: 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) GameObject obj = Models.ZiplinePole(height, parent, collider: true); ((Object)obj).name = name; obj.transform.position = at; Vector3 val = facing - at; val.y = 0f; obj.transform.rotation = Quaternion.LookRotation((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val)).normalized : Vector3.forward, Vector3.up); return obj.transform; } public static void Removed(Placement.Placed p) { if (p != null) { if (_riding && _line != null && _line.P == p) { EndRide(arrived: false); } All.Remove(p); } } public static void OnLoaded() { int count = All.Count; if (count > 0) { Instance log = Kit.Log; if (log != null) { log.Msg($"{count} zipline(s) strung."); } } } public static void Reset() { if (_riding) { EndRide(arrived: false); } All.Clear(); ClearStart(); DestroyGhost(); } public static bool TryUse(Placement.Placed p, RaycastHit hit, out string hint) { //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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) hint = null; if (!All.TryGetValue(p, out var value)) { return false; } bool fromA = true; Transform val = ((Component)((RaycastHit)(ref hit)).collider).transform; while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)p.Go.transform) { if ((Object)(object)val == (Object)(object)value.PoleB) { fromA = false; break; } if ((Object)(object)val == (Object)(object)value.PoleA) { fromA = true; break; } val = val.parent; } float value2 = Vector3.Distance(value.TopA, value.TopB); hint = $"[{Core.ViewKey}] Ride the zipline ({value2:0} m) [{"Hold Right Click"}] Take the zipline down"; if (Time.unscaledTime - _endedAt > 0.5f && FortifyApi.KeyDown(Core.ViewKey)) { StartRide(value, fromA); } return true; } private static void StartRide(Line line, bool fromA) { //IL_002b: 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) PlayerMovement instance = PlayerSingleton<PlayerMovement>.Instance; if (!((Object)(object)instance == (Object)null)) { _line = line; _forward = fromA; _t = 0f; _duration = Mathf.Max(2.5f, Vector3.Distance(line.TopA, line.TopB) / ZiplineCore.Speed); _riding = true; Placement.HideGhost(); instance.CanMove = false; ZiplineSound.Start(); } } public static void Update() { //IL_00e9: 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_00ee: 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_00fb: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: 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_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) if (!ZiplineCore_Equipped()) { ClearStartIfUnequipped(); } else if (_start.HasValue && Mouse1Down()) { Instance log = Kit.Log; if (log != null) { log.Msg("Zipline: starting over."); } ClearStart(); HideGhost(); } if (!_riding) { return; } PlayerMovement instance = PlayerSingleton<PlayerMovement>.Instance; if ((Object)(object)instance == (Object)null || _line == null || (Object)(object)_line.P.Go == (Object)null) { _riding = false; return; } _t += Time.deltaTime / _duration; float t = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(_t)); float num = Mathf.Clamp01(_t); ZiplineSound.SetSpeed(6f * num * (1f - num) / 1.5f); Vector3 val = (_forward ? _line.TopA : _line.TopB); Vector3 val2 = (_forward ? _line.TopB : _line.TopA); Vector3 val3 = Point(val, val2, _line.Sag, t) + Vector3.down * 1.8f; try { Vector3 val4 = val2 - val; val4.y = 0f; instance.Teleport(val3, Quaternion.LookRotation(((Vector3)(ref val4)).normalized, Vector3.up), true); } catch { } if (_t >= 1f) { EndRide(arrived: true); } } private static void EndRide(bool arrived) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //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) _riding = false; _endedAt = Time.unscaledTime; ZiplineSound.Stop(arrived); PlayerMovement instance = PlayerSingleton<PlayerMovement>.Instance; if ((Object)(object)instance == (Object)null) { return; } try { if (arrived && _line != null) { Vector3 val = (_forward ? _line.BaseB : _line.BaseA); Transform val2 = (_forward ? _line.PoleB : _line.PoleA); Vector3 val3 = (((Object)(object)val2 != (Object)null) ? (val2.forward * 1.6f) : Vector3.zero); instance.Teleport(val + val3 + Vector3.up * 0.1f, true); } instance.CanMove = true; } catch { } _line = null; } public static void DrawGui() { //IL_0043: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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) if (_riding && FortifyApi.InGame) { Rect r = default(Rect); ((Rect)(ref r))..ctor((float)Screen.width * 0.5f - 90f, (float)Screen.height - 120f, 180f, 30f); FortifyApi.UiFill(r, new Color(0f, 0f, 0f, 0.5f)); FortifyApi.UiFill(new Rect(((Rect)(ref r)).x + 4f, ((Rect)(ref r)).y + ((Rect)(ref r)).height - 6f, (((Rect)(ref r)).width - 8f) * Mathf.Clamp01(_t), 3f), new Color(1f, 0.8f, 0.2f, 0.9f)); FortifyApi.UiText(r, "Ziplining", 16, Color.white, (TextAnchor)4); } } private static bool ZiplineCore_Equipped() { return string.Equals(Placement.EquippedId(), "zl_zipline_kit", StringComparison.OrdinalIgnoreCase); } private static void ClearStartIfUnequipped() { HideGhost(); if (_start.HasValue) { Instance log = Kit.Log; if (log != null) { log.Msg("Zipline: the kit was put away, so the first pole was taken back."); } ClearStart(); } } private static bool Mouse1Down() { try { return GameInput.GetButtonDown((ButtonCode)1); } catch { return Keys.MouseDown(1); } } } public sealed class ZiplineCore : MelonMod { internal const string KitId = "zl_zipline_kit"; internal const float MinLength = 8f; internal const float MaxLength = 300f; private static MelonPreferences_Entry<float> _speed; private static MelonPreferences_Entry<float> _price; internal static float Speed => Mathf.Clamp(_speed?.Value ?? 14f, 4f, 60f); public override void OnInitializeMelon() { //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) try { Host.Init((MelonMod)(object)this, "Zipline", "Zipline", "zl_", null, Lines.OnLoaded, Lines.Reset); MelonPreferences_Category category = MelonPreferences.GetCategory("Zipline"); _speed = category.CreateEntry<float>("RideSpeed", 14f, "Ride speed", "How fast you ride, in metres per second (4 to 60).", false, false, (ValueValidator)null, (string)null); _price = category.CreateEntry<float>("PriceMultiplier", 1f, "Price multiplier", "Multiplies the kit's shop price (1 = normal, 0 = free). Applies after a game restart.", false, false, (ValueValidator)null, (string)null); Kit.PriceMultiplier = () => _price?.Value ?? 1f; FortifyApi.SetNotifyIcon("metalsign"); Catalog.Add(new ItemSpec { Id = "zl_zipline_kit", Name = "Zipline Kit", Price = 400f, Kind = PlaceKind.Ground, StackLimit = 5, RotateStep = 0f, IconColor = new Color(0.95f, 0.75f, 0.1f), Description = "Two steel poles and a cable. Place the first pole, then go to where you want the line to end (8 to 300 m away) and place the second. The poles grow tall enough for the cable to clear what's in between. Press E at either pole to ride.", BuildModel = () => Models.ZiplinePole(6.5f, Models.Root, collider: true), IconModel = Models.ZiplineKitIcon }); Kit.CustomPlace["zl_zipline_kit"] = Lines.Place; Kit.Use["zl_zipline_kit"] = Lines.TryUse; Kit.Created += Lines.Build; Kit.Removed += Lines.Removed; Kit.Busy = () => Lines.Riding; Kit.DevGiveKey = (KeyCode)122; Host.Ok = true; ((MelonBase)this).LoggerInstance.Msg("Zipline loaded. The Zipline Kit is at Dan's Hardware and Handy Hank's Hardware."); } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Error("Zipline couldn't start: " + ex.Message + ". It needs MelonLoader 0.7 and S1API (Bars fork) 3.2.3 or newer."); } } public override void OnUpdate() { if (!Host.Update()) { return; } try { Lines.Update(); } catch (Exception ex) { if (Time.frameCount % 600 == 0) { ((MelonBase)this).LoggerInstance.Warning("Zipline: " + ex.Message); } } } public override void OnGUI() { Host.DrawHint(); try { Lines.DrawGui(); } catch { } } } internal static class ZiplineSound { private static AudioSource _whir; private static AudioSource _fx; private static AudioClip _loop; private static AudioClip _clack; private static AudioClip _land; private static AudioClip Make(string name, float seconds, Func<float, float> wave) { int num = (int)(seconds * 22050f); float[] array = new float[num]; for (int i = 0; i < num; i++) { array[i] = Mathf.Clamp(wave((float)i / 22050f), -1f, 1f); } AudioClip obj = AudioClip.Create(name, num, 1, 22050, false); obj.SetData(new Il2CppStructArray<float>(array), 0); ((Object)obj).hideFlags = (HideFlags)32; return obj; } public static void Prewarm() { try { Ensure(); } catch { } } private static void Ensure() { //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_0026: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_whir != (Object)null)) { GameObject val = new GameObject("ZL_Audio"); Object.DontDestroyOnLoad((Object)val); _whir = val.AddComponent<AudioSource>(); _whir.loop = true; _whir.spatialBlend = 0f; _whir.playOnAwake = false; _whir.volume = 0f; _fx = val.AddComponent<AudioSource>(); _fx.spatialBlend = 0f; _fx.playOnAwake = false; _fx.volume = 0.7f; Random rng = new Random(9); float lp = 0f; float hp = 0f; float prev = 0f; _loop = Make("ZL_Whir", 2f, delegate(float t) { float num = (float)rng.NextDouble() * 2f - 1f; lp += (num - lp) * 0.35f; hp = lp - prev; prev = lp; float num2 = 0.6f + 0.4f * Mathf.Sin((float)Math.PI * 36f * t); float num3 = 0.25f * Mathf.Sin((float)Math.PI * 392f * t) + 0.12f * Mathf.Sin((float)Math.PI * 784f * t + 0.7f); float num4 = Mathf.Min(1f, Mathf.Min(t, 2f - t) / 0.05f); return (hp * 1.6f * num2 + num3 * 0.6f) * 0.5f * Mathf.Lerp(0.85f, 1f, num4); }); _clack = Make("ZL_Clack", 0.25f, (float t) => Mathf.Exp((0f - t) * 28f) * (Mathf.Sin((float)Math.PI * 1800f * t) * 0.6f + Mathf.Sin((float)Math.PI * 2740f * t) * 0.4f)); _land = Make("ZL_Land", 0.35f, (float t) => Mathf.Exp((0f - t) * 14f) * Mathf.Sin((float)Math.PI * 2f * (110f - 60f * t) * t) * 0.9f); } } public static void Start() { try { Ensure(); _fx.PlayOneShot(_clack); _whir.clip = _loop; _whir.volume = 0f; _whir.pitch = 0.7f; _whir.Play(); } catch { } } public static void SetSpeed(float f) { if (!((Object)(object)_whir == (Object)null)) { f = Mathf.Clamp01(f); _whir.volume = 0.15f + 0.55f * f; _whir.pitch = 0.7f + 0.7f * f; } } public static void Stop(bool landed) { try { if ((Object)(object)_whir != (Object)null) { _whir.Stop(); } if (landed && (Object)(object)_fx != (Object)null) { _fx.PlayOneShot(_land); } } catch { } } } } namespace WoodKit { internal static class Catalog { public static readonly List<ItemSpec> Items = new List<ItemSpec>(); private static readonly Dictionary<string, ItemSpec> ById = new Dictionary<string, ItemSpec>(StringComparer.OrdinalIgnoreCase); public static void Add(ItemSpec s) { Items.Add(s); ById[s.Id] = s; } public static ItemSpec Get(string id) { if (string.IsNullOrEmpty(id) || !ById.TryGetValue(id, out var value)) { return null; } return value; } public static void BuildTemplates() { foreach (ItemSpec item in Items) { if ((Object)(object)item.Template != (Object)null || item.BuildModel == null) { continue; } try { item.Template = item.BuildModel(); if ((Object)(object)item.Template != (Object)null && (Object)(object)item.Template.transform.parent == (Object)null) { item.Template.transform.SetParent(Models.Root, false); } } catch (Exception ex) { Instance log = Kit.Log; if (log != null) { log.Error("Couldn't build the " + item.Name + " model: " + ex.Message); } } } } } internal static class Core { internal const string PickupLabel = "Hold Right Click"; public static Instance Log => Kit.Log; public static KeyCode ViewKey => FortifyApi.UseKey; public static KeyCode RotateKey => Kit.RotateKey; } internal static class GltfLoader { public static GameObject LoadEmbedded(string fileName, Transform parent) { using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(Kit.ModelResourcePrefix + fileName); if (stream == null) { throw new FileNotFoundException("Embedded model missing: " + fileName); } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); return Load(memoryStream.ToArray(), Path.GetFileNameWithoutExtension(fileName), parent); } public static GameObject Load(byte[] glb, string name, Transform parent) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown if (glb.Length < 20 || BitConverter.ToUInt32(glb, 0) != 1179937895) { throw new InvalidDataException("Not a GLB file"); } int num = (int)BitConverter.ToUInt32(glb, 12); string json = Encoding.UTF8.GetString(glb, 20, num); int bin = 20 + num + 8; using JsonDocument jsonDocument = JsonDocument.Parse(json); JsonElement rootElement = jsonDocument.RootElement; Material[] materials = BuildMaterials(rootElement); Dictionary<int, (Mesh, Material[])> meshCache = new Dictionary<int, (Mesh, Material[])>(); GameObject val = new GameObject(name); val.transform.SetParent(parent, false); JsonElement property = rootElement.GetProperty("nodes"); HashSet<int> hashSet = new HashSet<int>(); for (int i = 0; i < property.GetArrayLength(); i++) { if (!property[i].TryGetProperty("children", out var value)) { continue; } foreach (JsonElement item in value.EnumerateArray()) { hashSet.Add(item.GetInt32()); } } for (int j = 0; j < property.GetArrayLength(); j++) { if (!hashSet.Contains(j)) { BuildNode(rootElement, property, j, val.transform, glb, bin, materials, meshCache); } } return val; } private static void BuildNode(JsonElement root, JsonElement nodes, int index, Transform parent, byte[] glb, int bin, Material[] materials, Dictionary<int, (Mesh, Material[])> meshCache) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) JsonElement jsonElement = nodes[index]; JsonElement value; GameObject val = new GameObject(jsonElement.TryGetProperty("name", out value) ? value.GetString() : ("node" + index)); Transform transform = val.transform; transform.SetParent(parent, false); if (jsonElement.TryGetProperty("translation", out var value2)) { transform.localPosition = new Vector3(value2[0].GetSingle(), value2[1].GetSingle(), 0f - value2[2].GetSingle()); } if (jsonElement.TryGetProperty("rotation", out var value3)) { transform.localRotation = new Quaternion(0f - value3[0].GetSingle(), 0f - value3[1].GetSingle(), value3[2].GetSingle(), value3[3].GetSingle()); } if (jsonElement.TryGetProperty("scale", out var value4)) { transform.localScale = new Vector3(value4[0].GetSingle(), value4[1].GetSingle(), value4[2].GetSingle()); } if (jsonElement.TryGetProperty("mesh", out var value5)) { int @int = value5.GetInt32(); if (!meshCache.TryGetValue(@int, out var value6)) { (Mesh, Material[]) tuple = (meshCache[@int] = BuildMesh(root, @int, glb, bin, materials)); value6 = tuple; } val.AddComponent<MeshFilter>().sharedMesh = value6.Item1; MeshRenderer val2 = val.AddComponent<MeshRenderer>(); Il2CppReferenceArray<Material> val3 = new Il2CppReferenceArray<Material>((long)value6.Item2.Length); for (int i = 0; i < value6.Item2.Length; i++) { ((Il2CppArrayBase<Material>)(object)val3)[i] = value6.Item2[i]; } ((Renderer)val2).sharedMaterials = val3; } if (!jsonElement.TryGetProperty("children", out var value7)) { return; } foreach (JsonElement item in value7.EnumerateArray()) { BuildNode(root, nodes, item.GetInt32(), transform, glb, bin, materials, meshCache); } } private static (Mesh, Material[]) BuildMesh(JsonElement root, int meshIndex, byte[] glb, int bin, Material[] materials) { //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_011f: 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_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) JsonElement property = root.GetProperty("meshes")[meshIndex].GetProperty("primitives"); List<Vector3> list = new List<Vector3>(); List<Vector3> list2 = new List<Vector3>(); List<Vector2> list3 = new List<Vector2>(); List<int[]> list4 = new List<int[]>(); List<Material> list5 = new List<Material>(); foreach (JsonElement item in property.EnumerateArray()) { JsonElement property2 = item.GetProperty("attributes"); int count = list.Count; int count2; float[] array = ReadFloats(root, property2.GetProperty("POSITION").GetInt32(), glb, bin, out count2); for (int i = 0; i < count2; i++) { list.Add(new Vector3(array[i * 3], array[i * 3 + 1], 0f - array[i * 3 + 2])); } int count3; if (property2.TryGetProperty("NORMAL", out var value)) { float[] array2 = ReadFloats(root, value.GetInt32(), glb, bin, out count3); for (int j = 0; j < count2; j++) { list2.Add(new Vector3(array2[j * 3], array2[j * 3 + 1], 0f - array2[j * 3 + 2])); } } else { for (int k = 0; k < count2; k++) { list2.Add(Vector3.up); } } if (property2.TryGetProperty("TEXCOORD_0", out var value2)) { float[] array3 = ReadFloats(root, value2.GetInt32(), glb, bin, out count3); for (int l = 0; l < count2; l++) { list3.Add(new Vector2(array3[l * 2], 1f - array3[l * 2 + 1])); } } else { for (int m = 0; m < count2; m++) { list3.Add(Vector2.zero); } } int[] array4; if (item.TryGetProperty("indices", out var value3)) { array4 = ReadIndices(root, value3.GetInt32(), glb, bin); } else { array4 = new int[count2]; for (int n = 0; n < count2; n++) { array4[n] = n; } } for (int num = 0; num + 2 < array4.Length; num += 3) { int num2 = array4[num] + count; int num3 = array4[num + 1] + count; int num4 = array4[num + 2] + count; array4[num] = num2; array4[num + 1] = num4; array4[num + 2] = num3; } list4.Add(array4); JsonElement value4; int num5 = (item.TryGetProperty("material", out value4) ? value4.GetInt32() : (-1)); list5.Add((num5 >= 0 && num5 < materials.Length) ? materials[num5] : Models.Mat("gltf_default", Color.gray)); } Mesh val = new Mesh { name = "HTF_" + meshIndex }; if (list.Count > 65000) { val.indexFormat = (IndexFormat)1; } val.vertices = new Il2CppStructArray<Vector3>(list.ToArray()); val.normals = new Il2CppStructArray<Vector3>(list2.ToArray()); val.uv = new Il2CppStructArray<Vector2>(list3.ToArray()); val.subMeshCount = list4.Count; for (int num6 = 0; num6 < list4.Count; num6++) { val.SetTriangles(new Il2CppStructArray<int>(list4[num6]), num6); } val.RecalculateBounds(); ((Object)val).hideFlags = (HideFlags)32; return (val, list5.ToArray()); } private static Material[] BuildMaterials(JsonElement root) { //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_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) if (!root.TryGetProperty("materials", out var value)) { return Array.Empty<Material>(); } Material[] array = (Material[])(object)new Material[value.GetArrayLength()]; for (int i = 0; i < array.Length; i++) { JsonElement jsonElement = value[i]; JsonElement value2; string text = (jsonElement.TryGetProperty("name", out value2) ? value2.GetString() : ("mat" + i)); Color white = Color.white; float metallic = 1f; float num = 1f; if (jsonElement.TryGetProperty("pbrMetallicRoughness", out var value3)) { if (value3.TryGetProperty("baseColorFactor", out var value4)) { ((Color)(ref white))..ctor(value4[0].GetSingle(), value4[1].GetSingle(), value4[2].GetSingle(), value4[3].GetSingle()); } if (value3.TryGetProperty("metallicFactor", out var value5)) { metallic = value5.GetSingle(); } if (value3.TryGetProperty("roughnessFactor", out var value6)) { num = value6.GetSingle(); } } Color? emission = null; if (jsonElement.TryGetProperty("emissiveFactor", out var value7)) { float num2 = 1f; if (jsonElement.TryGetProperty("extensions", out var value8) && value8.TryGetProperty("KHR_materials_emissive_strength", out var value9) && value9.TryGetProperty("emissiveStrength", out var value10)) { num2 = value10.GetSingle(); } Color value11 = new Color(value7[0].GetSingle(), value7[1].GetSingle(), value7[2].GetSingle()) * Mathf.Min(num2, 8f) * 0.5f; if (((Color)(ref value11)).maxColorComponent > 0.001f) { emission = value11; } } array[i] = Models.Mat("glb_" + text, white, metallic, 1f - num, emission); } return array; } private static float[] ReadFloats(JsonElement root, int accessor, byte[] glb, int bin, out int count) { JsonElement jsonElement = root.GetProperty("accessors")[accessor]; count = jsonElement.GetProperty("count").GetInt32(); int num = Components(jsonElement.GetProperty("type").GetString()); JsonElement jsonElement2 = root.GetProperty("bufferViews")[jsonElement.GetProperty("bufferView").GetInt32()]; JsonElement value; JsonElement value2; int num2 = bin + (jsonElement2.TryGetProperty("byteOffset", out value) ? value.GetInt32() : 0) + (jsonElement.TryGetProperty("byteOffset", out value2) ? value2.GetInt32() : 0); JsonElement value3; int num3 = (jsonElement2.TryGetProperty("byteStride", out value3) ? value3.GetInt32() : (num * 4)); float[] array = new float[count * num]; for (int i = 0; i < count; i++) { for (int j = 0; j < num; j++) { array[i * num + j] = BitConverter.ToSingle(glb, num2 + i * num3 + j * 4); } } return array; } private static int[] ReadIndices(JsonElement root, int accessor, byte[] glb, int bin) { JsonElement jsonElement = root.GetProperty("accessors")[accessor]; int @int = jsonElement.GetProperty("count").GetInt32(); int int2 = jsonElement.GetProperty("componentType").GetInt32(); JsonElement value; JsonElement value2; int num = bin + (root.GetProperty("bufferViews")[jsonElement.GetProperty("bufferView").GetInt32()].TryGetProperty("byteOffset", out value) ? value.GetInt32() : 0) + (jsonElement.TryGetProperty("byteOffset", out value2) ? value2.GetInt32() : 0); int[] array = new int[@int]; for (int i = 0; i < @int; i++) { int[] array2 = array; int num2 = i; int[] array3 = array2; int num3 = num2; array3[num3] = int2 switch { 5121 => glb[num + i], 5123 => BitConverter.ToUInt16(glb, num + i * 2), _ => (int)BitConverter.ToUInt32(glb, num + i * 4), }; } return array; } private static int Components(string type) { return type switch { "SCALAR" => 1, "VEC2" => 2, "VEC3" => 3, "VEC4" => 4, _ => 1, }; } } internal static class Host { public static bool Ok; private static bool _linkedTold; private static string _linkedNote; private static Action _onLoaded; private static Action _onUnloaded; private static string _folder; public static void Init(MelonMod mod, string folder, string title, string prefix, string linkedNote = null, Action onLoaded = null, Action onUnloaded = null) { _folder = folder; Kit.Log = ((MelonBase)mod).LoggerInstance; Kit.Prefix = prefix; Kit.Title = title; Kit.ModelResourcePrefix = ((object)mod).GetType().Namespace + ".models."; FortifyApi.Init(mod, folder, title); _linkedNote = linkedNote; _onLoaded = onLoaded; _onUnloaded = onUnloaded; FortifyApi.AfterLoad += Loaded; FortifyApi.BeforeSave += Placement.Save; FortifyApi.Unloaded += Unloaded; } private static void Loaded() { Registration.ResetForNewScene(); Placement.Load(); try { _onLoaded?.Invoke(); } catch (Exception ex) { Instance log = Kit.Log; if (log != null) { log.Warning("Loading: " + ex.Message); } } MelonCoroutines.Start(Registration.RenderIcons()); } private static void Unloaded() { try { _onUnloaded?.Invoke(); } catch { } Placement.Reset(); } public static bool Update() { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) if (!Ok) { return false; } try { Registration.TryRegister(); } catch { } if (!FortifyApi.InGame) { return false; } FortifyApi.Frame(); if (FortifyApi.Linked && _linkedNote != null) { if (!_linkedTold) { _linkedTold = true; Instance log = Kit.Log; if (log != null) { log.Msg(_linkedNote); } TellLinkedOnce(); } } else { Registration.TryAddToShops(); } try { Placement.Update(); } catch (Exception ex) { if (Time.frameCount % 600 == 0) { Instance log2 = Kit.Log; if (log2 != null) { log2.Warning("Placement: " + ex.Message); } } } if (FortifyApi.DevKeys && FortifyApi.KeyHeld((KeyCode)308) && FortifyApi.KeyDown(Kit.DevGiveKey)) { Placement.DevGive(); } return true; } private static void TellLinkedOnce() { try { MelonPreferences_Category val = MelonPreferences.GetCategory(_folder) ?? MelonPreferences.CreateCategory(_folder, Kit.Title); MelonPreferences_Entry<bool> val2 = val.GetEntry<bool>("LinkedNoticeShown") ?? val.CreateEntry<bool>("LinkedNoticeShown", false, "Linked notice shown", "Set once the in-game note about Fortify Your Base has been shown.", true, false, (ValueValidator)null, (string)null); if (!val2.Value) { val2.Value = true; FortifyApi.Notify(Kit.Title, "Fortify Your Base already sells these at the hardware stores."); MelonPreferences.Save(); } } catch { } } public static void DrawHint() { if (!Ok || !FortifyApi.InGame) { return; } try { FortifyApi.Hint(Placement.Hint); PickupHold.Draw(); } catch { } } } internal static class InputUtil { private static bool _legacyBroken; public static bool Suppressed; public static KeyCode Parse(string name, KeyCode fallback) { //IL_001a: 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) if (!string.IsNullOrWhiteSpace(name) && Enum.TryParse<KeyCode>(name.Trim(), ignoreCase: true, out KeyCode result)) { return result; } return fallback; } public static bool Down(KeyCode key) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!Suppressed) { return RawDown(key); } return false; } public static bool Held(KeyCode key) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!Suppressed) { return RawHeld(key); } return false; } public static bool RawDown(KeyCode key) { //IL_0019: 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) if (!_legacyBroken) { try { return Input.GetKeyDown(key); } catch { _legacyBroken = true; } } KeyControl obj2 = Control(key); if (obj2 == null) { return false; } return ((ButtonControl)obj2).wasPressedThisFrame; } public static bool RawHeld(KeyCode key) { //IL_0019: 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) if (!_legacyBroken) { try { return Input.GetKey(key); } catch { _legacyBroken = true; } } KeyControl obj2 = Control(key); if (obj2 == null) { return false; } return ((ButtonControl)obj2).isPressed; } public static bool MouseDown(int button) { if (!_legacyBroken) { try { return Input.GetMouseButtonDown(button); } catch { _legacyBroken = true; } } try { Mouse current = Mouse.current; if (current == null) { return false; } return (button == 0) ? current.leftButton.wasPressedThisFrame : current.rightButton.wasPressedThisFrame; } catch { return false; } } public static bool MouseHeld(int button) { if (!_legacyBroken) { try { return Input.GetMouseButton(button); } catch { _legacyBroken = true; } } try { Mouse current = Mouse.current; if (current == null) { return false; } return (button == 0) ? current.leftButton.isPressed : current.rightButton.isPressed; } catch { return false; } } private unsafe static KeyControl Control(KeyCode key) { //IL_0098: Unknown result type (might be due to invalid IL or missing references) try { Keyboard current = Keyboard.current; if (current == null) { return null; } string text = ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString(); if (text.StartsWith("Alpha")) { text = "Digit" + text.Substring(5); } else if (text == "Return") { text = "Enter"; } else if (text == "KeypadEnter") { text = "NumpadEnter"; } else if (text.StartsWith("Keypad")) { text = "Numpad" + text.Substring(6); } if (!Enum.TryParse<Key>(text, ignoreCase: true, out Key result)) { return null; } return current[result]; } catch { return null; } } } internal sealed class ItemSpec { public string Id; public string Name; public string Description; public float Price; public PlaceKind Kind; public int StackLimit = 10; public float RotateStep = 90f; public Color IconColor = Color.gray; public Func<GameObject> BuildModel; public Func<GameObject> IconModel; public string[] Stores; public bool NotSold; public float FitLift; public Bounds? FitBounds; public GameObject Template; } internal static class Kit { public delegate bool UseHandler(Placement.Placed p, RaycastHit hit, out string hint); public delegate bool Placer(ItemSpec spec, Camera cam, Player player, out string hint); public static string Prefix = "wk_"; public static string ModelResourcePrefix = "WoodKit.models."; public static string Title = "Wood Studios"; public static string SaveKey = "Items"; public static Instance Log; public static string[] Stores = new string[2] { "Dan's Hardware", "Handy Hank's Hardware" }; public static Func<float> PriceMultiplier = () => 1f; public static KeyCode RotateKey = (KeyCode)114; public static KeyCode DevGiveKey = (KeyCode)117; public static readonly Dictionary<string, UseHandler> Use = new Dictionary<string, UseHandler>(StringComparer.OrdinalIgnoreCase); public static readonly Dictionary<string, Placer> CustomPlace = new Dictionary<string, Placer>(StringComparer.OrdinalIgnoreCase); public static Func<bool> Busy = () => false; public static Func<Placement.Placed, bool> CanPickUp; public static event Action<Placement.Placed> Created; public static event Action<Placement.Placed> Removed; internal static void RaiseCreated(Placement.Placed p) { try { Kit.Created?.Invoke(p); } catch (Exception ex) { Instance log = Log; if (log != null) { log.Warning(p?.Spec?.Name + ": " + ex.Message); } } } internal static void RaiseRemoved(Placement.Placed p) { try { Kit.Removed?.Invoke(p); } catch (Exception ex) { Instance log = Log; if (log != null) { log.Warning(p?.Spec?.Name + ": " + ex.Message); } } } } internal static class Models { private static GameObject _root; private static readonly Dictionary<string, Material> Mats = new Dictionary<string, Material>(); private static Shader _litShader; public const float WallHeight = 2.4f; public const float WallThick = 0.25f; public static Transform Root { get { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown if ((Object)(object)_root == (Object)null) { _root = new GameObject(Kit.Prefix + "Templates"); _root.SetActive(false); Object.DontDestroyOnLoad((Object)(object)_root); } return _root.transform; } } internal static Material Concrete => Mat("concrete", new Color(0.58f, 0.58f, 0.56f), 0f, 0.12f); internal static Material Mortar => Mat("mortar", new Color(0.42f, 0.42f, 0.41f), 0f, 0.05f); internal static Material SteelDark => Mat("steel_dark", new Color(0.2f, 0.21f, 0.23f), 0.8f, 0.45f); internal static Material SteelLight => Mat("steel_light", new Color(0.55f, 0.57f, 0.6f), 0.85f, 0.55f); internal static Material Housing => Mat("housing", new Color(0.86f, 0.86f, 0.84f), 0.1f, 0.5f); internal static Material BlackPlastic => Mat("black", new Color(0.05f, 0.05f, 0.06f), 0.2f, 0.6f); internal static Material LedRed => Mat("led_red", new Color(1f, 0.1f, 0.1f), 0f, 0.8f, (Color?)new Color(4f, 0.2f, 0.2f)); internal static Material LensWarm => Mat("lens_warm", new Color(1f, 0.96f, 0.85f), 0f, 0.9f, (Color?)new Color(3f, 2.8f, 2.3f)); internal static Material Chain => Mat("chain", new Color(0.52f, 0.54f, 0.57f), 0.7f, 0.4f); internal static Material Burlap => Mat("burlap", new Color(0.62f, 0.55f, 0.4f), 0f, 0.05f); internal static Material Hazard => Mat("hazard", new Color(0.95f, 0.75f, 0.1f)); public static GameObject ZiplinePole(float height, Transform parent, bool collider) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_002f: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0197: 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_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("ZL_Pole"); val.transform.SetParent(parent, false); Transform transform = val.transform; ((Object)Box(transform, new Vector3(0f, 0.15f, 0f), new Vector3(0.7f, 0.3f, 0.7f), Concrete)).name = "Footing"; ((Object)Rod(transform, new Vector3(0f, height * 0.5f, 0f), 0.09f, height, SteelDark)).name = "Pole"; ((Object)Box(transform, new Vector3(0f, 0.9f, 0f), new Vector3(0.2f, 0.12f, 0.2f), Hazard)).name = "Band"; ((Object)Box(transform, new Vector3(0f, height - 0.05f, 0.3f), new Vector3(0.1f, 0.1f, 0.7f), SteelDark)).name = "Arm"; ((Object)Box(transform, new Vector3(0f, height - 0.35f, 0.15f), new Vector3(0.06f, 0.5f, 0.06f), SteelDark, (Vector3?)new Vector3(-35f, 0f, 0f))).name = "Brace"; ((Object)Rod(transform, new Vector3(0f, height - 0.05f, 0.55f), 0.08f, 0.05f, SteelLight, (Vector3?)new Vector3(0f, 0f, 90f))).name = "Pulley"; ((Object)Box(transform, new Vector3(0f, height - 1f, 0.55f), new Vector3(0.025f, 1.9f, 0.025f), SteelDark)).name = "Strap"; ((Object)Box(transform, new Vector3(0f, height - 1.95f, 0.55f), new Vector3(0.45f, 0.05f, 0.05f), Hazard)).name = "Handle"; Combine(transform); if (collider) { AddBoxCollider(val, new Vector3(0f, height * 0.5f, 0.2f), new Vector3(0.8f, height, 1f)); } Material mat = Mat("zip_lamp", new Color(1f, 0.85f, 0.55f), 0f, 0.5f, new Color(1f, 0.8f, 0.45f) * 3f); ((Object)Prim((PrimitiveType)0, transform, new Vector3(0f, height + 0.14f, 0f), new Vector3(0.24f, 0.24f, 0.24f), mat)).name = "Lamp"; AddPointLight(transform, "ZL_LampTop", new Vector3(0f, height + 0.3f, 0f), 9f, 1.6f, new Color(1f, 0.82f, 0.5f)); AddPointLight(transform, "ZL_LampBase", new Vector3(0f, 2.6f, 0.6f), 6f, 1.2f, new Color(1f, 0.82f, 0.5f)); return val; } public static GameObject ZiplineKitIcon() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0061: 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) GameObject val = new GameObject("ZL_KitIcon"); GameObject val2 = ZiplinePole(6.5f, val.transform, collider: false); foreach (Light componentsInChild in val2.GetComponentsInChildren<Light>(true)) { ((Behaviour)componentsInChild).enabled = false; } val2.transform.localScale = new Vector3(2.4f, 1f, 2.4f); val2.transform.localRotation = Quaternion.Euler(0f, 0f, -45f); return val; } public static GameObject Cable(Vector3 a, Vector3 b, float sag, Transform parent) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_002c: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_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_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_00ae: 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_00be: 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_00e6: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0114: 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) GameObject val = new GameObject("ZL_Cable"); val.transform.SetParent(parent, false); Material m = Mat("cable", new Color(0.15f, 0.15f, 0.16f), 0.8f, 0.5f); int num = Mathf.Clamp(Mathf.CeilToInt(Vector3.Distance(a, b) / 2f), 8, 300); Vector3 val2 = a; for (int i = 1; i <= num; i++) { float num2 = (float)i / (float)num; Vector3 val3 = Vector3.Lerp(a, b, num2) + Vector3.down * (4f * sag * num2 * (1f - num2)); GameObject obj = Box(val.transform, Vector3.zero, new Vector3(0.025f, 0.025f, Vector3.Distance(val2, val3) + 0.02f), m); obj.transform.position = (val2 + val3) * 0.5f; obj.transform.rotation = Quaternion.LookRotation(val3 - val2); val2 = val3; } Combine(val.transform); return val; } public static Sprite FallbackIcon(Color color) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_00bc: 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_0081: 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_0071: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false); Color val2 = default(Color); ((Color)(ref val2))..ctor(0f, 0f, 0f, 0f); for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { bool flag = i > 6 && i < 57 && j > 6 && j < 57; bool flag2 = flag && (i < 11 || i > 52 || j < 11 || j > 52); val.SetPixel(i, j, (!flag) ? val2 : (flag2 ? (color * 0.55f) : color)); } } val.Apply(); ((Object)val).hideFlags = (HideFlags)32; Sprite obj = Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f)); ((Object)obj).hideFlags = (HideFlags)32; return obj; } private static Shader LitShader() { if ((Object)(object)_litShader != (Object)null) { return _litShader; } _litShader = Shader.Find("Universal Render Pipeline/Lit"); if ((Object)(object)_litShader == (Object)null) { _litShader = Shader.Find("Universal Render Pipeline/Simple Lit"); } if ((Object)(object)_litShader == (Object)null) { foreach (Material item in Resources.FindObjectsOfTypeAll<Material>()) { if ((Object)(object)item != (Object)null && (Object)(object)item.shader != (Object)null && ((Object)item.shader).name.Contains("Lit")) { _litShader = item.shader; break; } } } if ((Object)(object)_litShader == (Object)null) { _litShader = Shader.Find("Standard"); } return _litShader; } public static Material Mat(string key, Color color, float metallic = 0f, float smoothness = 0.3f, Color? emission = null) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0037: 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_00ca: Unknown result type (might be due to invalid IL or missing references) if (Mats.TryGetValue(key, out var value) && (Object)(object)value != (Object)null) { return value; } Material val = new Material(LitShader()); ((Object)val).name = Kit.Prefix + key; val.color = color; if (val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", color); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", metallic); } if (val.HasProperty("_Smoothness")) { val.SetFloat("_Smoothness", smoothness); } if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", smoothness); } if (emission.HasValue) { val.EnableKeyword("_EMISSION"); if (val.HasProperty("_EmissionColor")) { val.SetColor("_EmissionColor", emission.Value); } val.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)1; } ((Object)val).hideFlags = (HideFlags)32; Mats[key] = val; return val; } internal static GameObject NewRoot(string name) { //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_0018: Expected O, but got Unknown GameObject val = new GameObject(name); val.transform.SetParent(Root, false); return val; } internal static GameObject Prim(PrimitiveType type, Transform parent, Vector3 pos, Vector3 scale, Material mat, Vector3? euler = null, bool keepCollider = false) { //IL_0000: 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_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_002f: 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) GameObject val = GameObject.CreatePrimitive(type); val.transform.SetParent(parent, false); val.transform.localPosition = pos; val.transform.localRotation = (euler.HasValue ? Quaternion.Euler(euler.Value) : Quaternion.identity); val.transform.localScale = scale; MeshRenderer component = val.GetComponent<MeshRenderer>(); if ((Object)(object)component != (Object)null) { ((Renderer)component).sharedMaterial = mat; } if (!keepCollider) { Collider component2 = val.GetComponent<Collider>(); if ((Object)(object)component2 != (Object)null) { Object.DestroyImmediate((Object)(object)component2); } } return val; } internal static GameObject Box(Transform p, Vector3 pos, Vector3 size, Material m, Vector3? euler = null) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) return Prim((PrimitiveType)3, p, pos, size, m, euler); } internal static GameObject Rod(Transform p, Vector3 pos, float radius, float height, Material m, Vector3? euler = null) { //IL_0002: 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) return Prim((PrimitiveType)2, p, pos, new Vector3(radius * 2f, height * 0.5f, radius * 2f), m, euler); } internal static void AddBoxCollider(GameObject go, Vector3 center, Vector3 size) { //IL_0007: 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) BoxCollider obj = go.AddComponent<BoxCollider>(); obj.center = center; obj.size = size; } internal static void NavBlock(GameObject go, Vector3 center, Vector3 size) { //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) AddNavObstacle(go, center, size); } private static void AddNavObstacle(GameObject go, Vector3 center, Vector3 size) { //IL_000e: 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) try { NavMeshObstacle obj = go.AddComponent<NavMeshObstacle>(); obj.shape = (NavMeshObstacleShape)1; obj.center = center; obj.size = size; obj.carving = true; } catch { } } public static void Combine(Transform root) { //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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_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_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Expected O, but got Unknown //IL_01da: 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_01ec: Unknown result type (might be due to invalid IL or missing references) Dictionary<int, List<MeshFilter>> dictionary = new Dictionary<int, List<MeshFilter>>(); Dictionary<int, Material> dictionary2 = new Dictionary<int, Material>(); foreach (MeshFilter componentsInChild in ((Component)root).GetComponentsInChildren<MeshFilter>(true)) { if ((Object)(object)((Component)componentsInChild).transform == (Object)(object)root || (Object)(object)componentsInChild.sharedMesh == (Object)null) { continue; } if (!componentsInChild.sharedMesh.isReadable) { return; } MeshRenderer component = ((Component)componentsInChild).GetComponent<MeshRenderer>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)((Renderer)component).sharedMaterial == (Object)null)) { int instanceID = ((Object)((Renderer)component).sharedMaterial).GetInstanceID(); if (!dictionary.TryGetValue(instanceID, out var value)) { List<MeshFilter> list = (dictionary[instanceID] = new List<MeshFilter>()); value = list; dictionary2[instanceID] = ((Renderer)component).sharedMaterial; } value.Add(componentsInChild); } } Matrix4x4 worldToLocalMatrix = root.worldToLocalMatrix; foreach (KeyValuePair<int, List<MeshFilter>> item in dictionary) { if (item.Value.Count < 2) { continue; } Il2CppStructArray<CombineInstance> val = new Il2CppStructArray<CombineInstance>((long)item.Value.Count); for (int i = 0; i < item.Value.Count; i++) { CombineInstance val2 = default(CombineInstance); ((CombineInstance)(ref val2)).mesh = item.Value[i].sharedMesh; ((CombineInstance)(ref val2)).transform = worldToLocalMatrix * ((Component)item.Value[i]).transform.localToWorldMatrix; ((Il2CppArrayBase<CombineInstance>)(object)val)[i] = val2; } Mesh val3 = new Mesh { name = "HTF_Combined" }; val3.indexFormat = (IndexFormat)1; val3.CombineMeshes(val, true, true); val3.RecalculateBounds(); ((Object)val3).hideFlags = (HideFlags)32; GameObject val4 = new GameObject("Combined_" + ((Object)dictionary2[item.Key]).name); val4.transform.SetParent(root, false); val4.AddComponent<MeshFilter>().sharedMesh = val3; ((Renderer)val4.AddComponent<MeshRenderer>()).sharedMaterial = dictionary2[item.Key]; foreach (MeshFilter item2 in item.Value) { Object.DestroyImmediate((Object)(object)((Component)item2).gameObject); } } } internal static void MeshColliders(GameObject root, params string[] prefixes) { foreach (MeshFilter componentsInChild in root.GetComponentsInChildren<MeshFilter>(true)) { foreach (string value in prefixes) { if (((Object)componentsInChild).name.StartsWith(value, StringComparison.Ordinal)) { ((Component)componentsInChild).gameObject.AddComponent<MeshCollider>().sharedMesh = componentsInChild.sharedMesh; break; } } } } internal static Light AddPointLight(Transform parent, string name, Vector3 local, float range, float intensity, Color color) { //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_0013: 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_003b: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); val.transform.localPosition = local; Light obj = val.AddComponent<Light>(); obj.type = (LightType)2; obj.range = range; obj.intensity = intensity; obj.color = color; obj.shadows = (LightShadows)0; return obj; } internal static AudioSource AddAudio(Transform parent, string name, Vector3 local, AudioClip clip, bool loop, bool playOnAwake, float volume, float maxDistance) { //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_0013: 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) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); val.transform.localPosition = local; AudioSource obj = val.AddComponent<AudioSource>(); obj.clip = clip; obj.loop = loop; obj.playOnAwake = playOnAwake; obj.spatialBlend = 1f; obj.rolloffMode = (AudioRolloffMode)1; obj.minDistance = 1.5f; obj.maxDistance = maxDistance; obj.volume = volume; return obj; } } internal static class PickupHold { private const float Seconds = 0.6f; private static float _start = -1f; private static int _target; private static int _lastFrame = -10; public static float Progress { get; private set; } public static bool Showing { get { if (Progress > 0f) { return Time.frameCount - _lastFrame <= 2; } return false; } } public static bool Held(GameObject target) { int num = (((Object)(object)target != (Object)null) ? ((Object)target).GetInstanceID() : 0); int frameCount = Time.frameCount; bool flag = frameCount - _lastFrame > 2; _lastFrame = frameCount; if (num == 0 || !MouseHeld() || HoldingWeapon()) { _start = -1f; Progress = 0f; _target = num; return false; } if (_start < 0f || num != _target || flag) { _target = num; Progress = 0f; if (!Keys.MouseDown(1)) { _start = -1f; return false; } _start = Time.unscaledTime; } Progress = Mathf.Clamp01((Time.unscaledTime - _start) / 0.6f); if (Progress < 1f) { return false; } _start = -1f; Progress = 0f; return true; } private static bool MouseHeld() { try { return Input.GetMouseButton(1); } catch { try { Mouse current = Mouse.current; return current != null && current.rightButton.isPressed; } catch { return false; } } } private static bool HoldingWeapon() { try { PlayerInventory instance = PlayerSingleton<PlayerInventory>.Instance; Equippable val = ((instance != null) ? instance.Equippable : null); if ((Object)(object)val == (Object)null) { return false; } return (Object)(object)((Il2CppObjectBase)val).TryCast<Equippable_RangedWeapon>() != (Object)null || (Object)(object)((Il2CppObjectBase)val).TryCast<Equippable_MeleeWeapon>() != (Object)null; } catch { return false; } } public static void Draw() { //IL_003f: 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_006f: 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) if (Showing) { float num = 220f; float num2 = (float)Screen.width * 0.5f - num * 0.5f; float num3 = (float)Screen.height * 0.68f + 40f; FortifyApi.UiFill(new Rect(num2, num3, num, 8f), new Color(0f, 0f, 0f, 0.6f)); FortifyApi.UiFill(new Rect(num2, num3, num * Progress, 8f), new Color(1f, 1f, 1f, 0.9f)); } } } internal sealed class PlacedRecord { public string Id { get; set; } public float[] Pos { get; set; } public float[] Rot { get; set; } public bool Active { get; set; } = true; public int Channel { get; set; } public string Text { get; set; } public float[] Extra { get; set; } } internal enum PlaceKind { Ground, Wall } internal static class Placement { internal sealed class Placed { public GameObject Go; public ItemSpec Spec; public PlacedRecord Rec; public bool Active = true; public int Channel; public string Text; public string Label; public Camera Feed; public bool OnShip; public Vector3[] Extra; public object State; } private const float PlaceReach = 8f; private const float UseReach = 3.5f; private const float Tile = 0.25f; private static readonly List<Placed> Items = new List<Placed>(); internal static int Version; private static GameObject _ghost; private static string _ghostId; private static Bounds _ghostLocalBounds; private static float _ghostLift; private static Bounds? _ghostFit; private static float _blockedLogAt = -100f; internal static string LastBlocker; private static bool _ghostShowingValid; private static int _rotIndex; private static float _turn; private const float FineTurn = 15f; private static string _hint; private static readonly HashSet<int> Ignored = new HashSet<int>(); private static float _ignoredRefreshAt; private static float _nearCheckAt; private static bool _anyNear; internal static List<Placed> All => Items; public static string Hint => _hint; internal static int Count(string id) { int num = 0; foreach (Placed item in Items) { if ((Object)(object)item.Go != (Object)null && string.Equals(item.Spec.Id, id, StringComparison.OrdinalIgnoreCase)) { num++; } } return num; } public static void Load() { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) Reset(); List<PlacedRecord> list = null; try { string data = FortifyApi.GetData(Kit.SaveKey); if (!string.IsNullOrEmpty(data)) { list = JsonSerializer.Deserialize<List<PlacedRecord>>(data); } } catch (Exception ex) { Instance log = Kit.Log; if (log != null) { log.Warning("Couldn't read the saved items (" + ex.Message + ")."); } } if (list == null) { return; } int num = 0; foreach (PlacedRecord item in list) { ItemSpec itemSpec = Catalog.Get(item?.Id); if (itemSpec != null && !((Object)(object)itemSpec.Template == (Object)null) && item.Pos != null && item.Rot != null) { Placed placed = Create(itemSpec, V(item.Pos), Q(item.Rot), item); Items.Add(placed); num++; Kit.RaiseCreated(placed); } } Version++; if (num > 0) { Instance log2 = Kit.Log; if (log2 != null) { log2.Msg($"Put back {num} placed item(s)."); } } } public static void Save() { try { List<PlacedRecord> list = new List<PlacedRecord>(); foreach (Placed item in Items) { if (!((Object)(object)item.Go == (Object)null)) { UpdateRecord(item); list.Add(item.Rec); } } FortifyApi.SetData(Kit.SaveKey, JsonSerializer.Serialize(list)); } catch (Exception ex) { Instance log = Kit.Log; if (log != null) { log.Warning("Couldn't save the placed items: " + ex.Message); } } } public static void Reset() { foreach (Placed item in Items) { Kit.RaiseRemoved(item); if ((Object)(object)item.Go != (Object)null) { Object.Destroy((Object)(object)item.Go); } } Items.Clear(); Version++; DestroyGhost(); _hint = null; _nearCheckAt = 0f; } internal static void UpdateRecord(Placed p) { //IL_0037: 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) Transform transform = p.Go.transform; if (p.Rec == null) { p.Rec = new PlacedRecord { Id = p.Spec.Id }; } p.Rec.Pos = F(transform.position); p.Rec.Rot = F(transform.rotation); p.Rec.Active = p.Active; p.Rec.Channel = p.Channel; p.Rec.Text = p.Text; if (p.Extra != null) { float[] array = new float[p.Extra.Length * 3]; for (int i = 0; i < p.Extra.Length; i++) { array[i * 3] = p.Extra[i].x; array[i * 3 + 1] = p.Extra[i].y; array[i * 3 + 2] = p.Extra[i].z; } p.Rec.Extra = array; } } public static void Update() { _hint = null; Player local = Player.Local; Camera camera = GetCamera(); if ((Object)(object)local == (Object)null || (Object)(object)camera == (Object)null || UiBusy(local)) { HideGhost(); return; } ItemSpec itemSpec = Catalog.Get(EquippedId()); if (itemSpec != null) { if (Kit.CustomPlace.TryGetValue(itemSpec.Id, out var value)) { HideGhost(); value(itemSpec, camera, local, out _hint); } else { UpdatePlacing(itemSpec, camera, local); } } else { HideGhost(); UpdateLooking(camera, local); } } private static void UpdatePlacing(ItemSpec spec, Camera cam, Player player) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: 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_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: 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_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0220: 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_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: 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_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (m