Decompiled source of Wanderburg Multiplayer v1.0.2
Mods/WanderNet.dll
Decompiled a day 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.IO; using System.IO.Compression; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using HarmonyLib; using Il2Cpp; using Il2CppDitzelGames.FastIK; using Il2CppHeathen.SteamworksIntegration; using Il2CppHeathen.SteamworksIntegration.API; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppRNGNeeds; using Il2CppSteamTools; using Il2CppSteamworks; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppSystem.Reflection; using Il2CppTMPro; using MelonLoader; using MelonLoader.Preferences; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using NetKit.Unity; using Unity.AI.Navigation; using UnityEngine; using UnityEngine.AI; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; using WanderNet; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(/*Could not decode attribute arguments.*/)] [assembly: MelonInfo(typeof(Mod), "WanderNet", "WBMP-1.0.2", "Mike", null)] [assembly: MelonGame("Randwerk", "Wanderburg")] [assembly: SecurityPermission((SecurityAction)8, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : System.Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(/*Could not decode attribute arguments.*/)] internal sealed class RefSafetyRulesAttribute : System.Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace NetKit.Unity { public static class ViewWall { public sealed class Shells { private GameObject go; private Mesh mesh; private float lastR = -1f; private float lastMin = -1f; private Vector3 lastAt; private int lastVer = -1; private float[] edge; public void Show(Vector3 at, float radius, Color color, float camHeight, float camDist, Func<Vector3, Vector3, float, float> reach = null, int reachVersion = 0) { //IL_000f: 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_0098: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)go == (Object)null) { Build(color); } if ((Object)(object)go == (Object)null) { return; } float num = Mathf.Min(radius, camDist + 12f); if (!(Mathf.Abs(lastR - radius) > 0.5f) && !(Mathf.Abs(lastMin - num) > 1f)) { Vector3 val = at - lastAt; if (!(((Vector3)(ref val)).sqrMagnitude > 4f) && reachVersion == lastVer) { goto IL_008d; } } Shape(at, radius, num, reach, reachVersion); goto IL_008d; IL_008d: go.transform.position = at; go.transform.localScale = new Vector3(1f, Mathf.Clamp(camHeight * 1.5f + 10f, 20f, Mathf.Max(20f, radius)), 1f); if (!go.activeSelf) { go.SetActive(true); } } public void Hide() { if ((Object)(object)go != (Object)null && go.activeSelf) { go.SetActive(false); } } private void Build(Color c) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown Shader val = Shader.Find("Sprites/Default"); if (!((Object)(object)val == (Object)null)) { Material val2 = new Material(val); val2.color = c; val2.renderQueue = 2990; go = new GameObject("NetKit_ViewWall"); Object.DontDestroyOnLoad((Object)(object)go); mesh = new Mesh(); go.AddComponent<MeshFilter>().sharedMesh = mesh; MeshRenderer obj = go.AddComponent<MeshRenderer>(); ((Renderer)obj).sharedMaterial = val2; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj).receiveShadows = false; } } private void Shape(Vector3 at, float R, float minR, Func<Vector3, Vector3, float, float> reach, int ver) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_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_0206: Unknown result type (might be due to invalid IL or missing references) lastR = R; lastMin = minR; lastAt = at; lastVer = ver; int segments = Segments; if (edge == null || edge.Length != segments + 1) { edge = new float[segments + 1]; } Vector3 val = default(Vector3); for (int i = 0; i < segments; i++) { float num = (float)i * (float)Math.PI * 2f / (float)segments; ((Vector3)(ref val))..ctor(Mathf.Sin(num), 0f, Mathf.Cos(num)); edge[i] = Mathf.Max(minR, reach?.Invoke(at, val, R) ?? R); } edge[segments] = edge[0]; float num2 = R * (1f - FadeFrom); int num3 = (segments + 1) * 2; Vector3[] array = (Vector3[])(object)new Vector3[Layers * num3]; Color[] array2 = (Color[])(object)new Color[array.Length]; int[] array3 = new int[Layers * segments * 6]; int num4 = 0; for (int j = 0; j < Layers; j++) { float num5 = num2 * (1f - (float)(j + 1) / (float)Layers); float num6 = ShellAlpha(j + 1, Layers); for (int k = 0; k <= segments; k++) { float num7 = (float)k * (float)Math.PI * 2f / (float)segments; float num8 = Mathf.Max(Mathf.Max(1f, minR), edge[k] - Mathf.Min(num2, edge[k] * 0.5f) * (num5 / Mathf.Max(0.001f, num2))); int num9 = j * num3 + k * 2; array[num9] = new Vector3(Mathf.Sin(num7) * num8, -0.25f, Mathf.Cos(num7) * num8); array[num9 + 1] = new Vector3(array[num9].x, 1f, array[num9].z); array2[num9] = (array2[num9 + 1] = new Color(1f, 1f, 1f, num6)); if (k < segments) { array3[num4++] = num9; array3[num4++] = num9 + 1; array3[num4++] = num9 + 2; array3[num4++] = num9 + 1; array3[num4++] = num9 + 3; array3[num4++] = num9 + 2; } } } mesh.Clear(); mesh.vertices = Il2CppStructArray<Vector3>.op_Implicit(array); mesh.colors = Il2CppStructArray<Color>.op_Implicit(array2); mesh.triangles = Il2CppStructArray<int>.op_Implicit(array3); mesh.bounds = new Bounds(new Vector3(0f, 0.4f, 0f), new Vector3(R * 2.2f, 1.5f, R * 2.2f)); } } public sealed class TopDownRing { public float Height = 60f; private GameObject go; public float PerSize; [field: CompilerGenerated] public float Radius { [CompilerGenerated] get; [CompilerGenerated] private set; } public void Show(Camera cam, Vector3 player, Color color) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cam == (Object)null || !cam.orthographic) { Hide(); return; } Transform transform = ((Component)cam).transform; Vector3 forward = transform.forward; Vector3 up = transform.up; if (forward.y > -0.05f) { Hide(); return; } Vector3 val = transform.position + up * Vector3.Dot(player - transform.position, up); Vector3 val2 = val + forward * ((player.y - val.y) / forward.y); Radius = ((PerSize > 0f) ? (cam.orthographicSize * PerSize) : (cam.orthographicSize * cam.aspect / FadeFrom)); if ((Object)(object)go == (Object)null) { Build(color); } if (!((Object)(object)go == (Object)null)) { go.transform.position = val2 - forward * (Height / (0f - forward.y)); go.transform.localScale = new Vector3(Radius, 1f, Radius); if (!go.activeSelf) { go.SetActive(true); } } } public void Hide() { if ((Object)(object)go != (Object)null && go.activeSelf) { go.SetActive(false); } } private void Build(Color c) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) Shader val = Shader.Find("Sprites/Default"); if ((Object)(object)val == (Object)null) { return; } Material val2 = new Material(val); val2.color = c; val2.renderQueue = 2995; go = new GameObject("NetKit_TopDownRing"); Object.DontDestroyOnLoad((Object)(object)go); Mesh val3 = new Mesh(); int num = 8; float[] array = new float[num + 2]; float[] array2 = new float[num + 2]; for (int i = 0; i <= num; i++) { float num2 = (float)i / (float)num; array[i] = FadeFrom + (1f - FadeFrom) * num2; array2[i] = Curve(num2); } array[num + 1] = 40f; array2[num + 1] = 1f; int num3 = array.Length; Vector3[] array3 = (Vector3[])(object)new Vector3[num3 * 181]; Color[] array4 = (Color[])(object)new Color[array3.Length]; int[] array5 = new int[(num3 - 1) * 180 * 6]; int num4 = 0; for (int j = 0; j < num3; j++) { for (int k = 0; k <= 180; k++) { float num5 = (float)k * (float)Math.PI * 2f / 180f; array3[j * 181 + k] = new Vector3(Mathf.Sin(num5) * array[j], 0f, Mathf.Cos(num5) * array[j]); array4[j * 181 + k] = new Color(1f, 1f, 1f, array2[j]); } } for (int l = 0; l < num3 - 1; l++) { for (int m = 0; m < 180; m++) { int num6 = l * 181 + m; int num7 = num6 + 180 + 1; array5[num4++] = num6; array5[num4++] = num7; array5[num4++] = num6 + 1; array5[num4++] = num6 + 1; array5[num4++] = num7; array5[num4++] = num7 + 1; } } val3.vertices = Il2CppStructArray<Vector3>.op_Implicit(array3); val3.colors = Il2CppStructArray<Color>.op_Implicit(array4); val3.triangles = Il2CppStructArray<int>.op_Implicit(array5); val3.bounds = new Bounds(Vector3.zero, new Vector3(80f, 1f, 80f)); go.AddComponent<MeshFilter>().sharedMesh = val3; MeshRenderer obj = go.AddComponent<MeshRenderer>(); ((Renderer)obj).sharedMaterial = val2; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj).receiveShadows = false; } } public sealed class ZoneMask { public float Cell = 2f; public float SeamTolerance = 10f; public float EdgeMargin = 4f; private Bounds area; private int nx; private int nz; private bool[] mask; [field: CompilerGenerated] public int Version { [CompilerGenerated] get; [CompilerGenerated] private set; } [field: CompilerGenerated] public bool Ready { [CompilerGenerated] get; [CompilerGenerated] private set; } public bool Build(System.Collections.Generic.IList<Renderer> tiles, System.Collections.Generic.IList<Vector3> knownInside) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0135: 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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: 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_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Expected O, but got Unknown //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) if (tiles == null || ((System.Collections.Generic.ICollection<Renderer>)tiles).Count == 0) { return false; } area = tiles[0].bounds; System.Collections.Generic.IEnumerator<Renderer> enumerator = ((System.Collections.Generic.IEnumerable<Renderer>)tiles).GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { Renderer current = enumerator.Current; ((Bounds)(ref area)).Encapsulate(current.bounds); } } finally { ((System.IDisposable)enumerator)?.Dispose(); } ((Bounds)(ref area)).Expand(new Vector3(Cell * 8f, 0f, Cell * 8f)); nx = Mathf.CeilToInt(((Bounds)(ref area)).size.x / Cell); nz = Mathf.CeilToInt(((Bounds)(ref area)).size.z / Cell); Shader val = Shader.Find("Sprites/Default"); if ((Object)(object)val == (Object)null) { return false; } Material val2 = new Material(val); val2.color = Color.white; RenderTexture val3 = new RenderTexture(nx, nz, 16, (RenderTextureFormat)0); val3.Create(); CommandBuffer val4 = new CommandBuffer(); val4.SetRenderTarget(RenderTargetIdentifier.op_Implicit((Texture)(object)val3)); val4.ClearRenderTarget(true, true, Color.black); Matrix4x4 val5 = Matrix4x4.TRS(new Vector3(((Bounds)(ref area)).center.x, ((Bounds)(ref area)).max.y + 50f, ((Bounds)(ref area)).center.z), Quaternion.Euler(90f, 0f, 0f), Vector3.one); val4.SetViewProjectionMatrices(Matrix4x4.Scale(new Vector3(1f, 1f, -1f)) * ((Matrix4x4)(ref val5)).inverse, Matrix4x4.Ortho((0f - ((Bounds)(ref area)).size.x) / 2f, ((Bounds)(ref area)).size.x / 2f, (0f - ((Bounds)(ref area)).size.z) / 2f, ((Bounds)(ref area)).size.z / 2f, 0.1f, ((Bounds)(ref area)).size.y + 200f)); enumerator = ((System.Collections.Generic.IEnumerable<Renderer>)tiles).GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { Renderer current2 = enumerator.Current; MeshFilter component = ((Component)current2).GetComponent<MeshFilter>(); int num = ((!((Object)(object)component != (Object)null) || !((Object)(object)component.sharedMesh != (Object)null)) ? 1 : component.sharedMesh.subMeshCount); for (int i = 0; i < num; i++) { val4.DrawRenderer(current2, val2, i, 0); } } } finally { ((System.IDisposable)enumerator)?.Dispose(); } Graphics.ExecuteCommandBuffer(val4); val4.Release(); RenderTexture active = RenderTexture.active; RenderTexture.active = val3; Texture2D val6 = new Texture2D(nx, nz, (TextureFormat)4, false); val6.ReadPixels(new Rect(0f, 0f, (float)nx, (float)nz), 0, 0); val6.Apply(); RenderTexture.active = active; Il2CppStructArray<Color32> pixels = val6.GetPixels32(); Object.Destroy((Object)val6); val3.Release(); Object.Destroy((Object)(object)val3); Object.Destroy((Object)(object)val2); bool[] array = new bool[nx * nz]; bool[] array2 = new bool[nx * nz]; int num2 = 0; for (int j = 0; j < nz; j++) { for (int k = 0; k < nx; k++) { bool flag = ((Il2CppArrayBase<Color32>)(object)pixels)[j * nx + k].r > 128; array[j * nx + k] = flag; array2[(nz - 1 - j) * nx + k] = flag; if (flag) { num2++; } } } if (num2 == 0) { return false; } int num3 = 0; int num4 = 0; if (knownInside != null) { System.Collections.Generic.IEnumerator<Vector3> enumerator2 = ((System.Collections.Generic.IEnumerable<Vector3>)knownInside).GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator2).MoveNext()) { Vector3 current3 = enumerator2.Current; int num5 = Index(current3.x, current3.z); if (num5 >= 0) { if (array[num5]) { num3++; } if (array2[num5]) { num4++; } } } } finally { ((System.IDisposable)enumerator2)?.Dispose(); } } mask = ((num4 > num3) ? array2 : array); Ready = true; Version++; return true; } private int Index(float x, float z) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.FloorToInt((x - ((Bounds)(ref area)).min.x) / Cell); int num2 = Mathf.FloorToInt((z - ((Bounds)(ref area)).min.z) / Cell); if (num >= 0 && num2 >= 0 && num < nx && num2 < nz) { return num2 * nx + num; } return -1; } public bool Inside(float x, float z) { if (!Ready) { return true; } int num = Index(x, z); if (num >= 0) { return mask[num]; } return false; } public float Reach(Vector3 from, Vector3 dir, float max) { //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_0025: 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_0047: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) if (!Ready) { return max; } for (float num = 8f; num < max; num += Cell) { if (Inside(from.x + dir.x * num, from.z + dir.z * num)) { continue; } bool flag = false; for (float num2 = Cell; num2 <= SeamTolerance; num2 += Cell) { if (Inside(from.x + dir.x * (num + num2), from.z + dir.z * (num + num2))) { flag = true; num += num2; break; } } if (!flag) { return Mathf.Min(max, num + EdgeMargin); } } return max; } } public static float FadeFrom = 0.5f; public const float CurvePower = 1.943f; public static int Layers = 10; public static int Segments = 180; public static float Curve(float t) { t = Mathf.Clamp01(t); return 1f - Mathf.Pow(1f - t, 1.943f); } public static float ShellAlpha(int k, int n) { float num = 1f - Curve((float)(k - 1) / (float)n); float num2 = 1f - Curve((float)k / (float)n); if (!(num <= 1E-05f)) { return 1f - num2 / num; } return 1f; } public static float Measure(Quaternion camRot, Vector3 camOffset, bool ortho, float orthoSize, float fov, float aspect) { //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_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_0104: 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_0116: 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_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = camRot * Vector3.forward; Vector3 val2 = camRot * Vector3.right; Vector3 val3 = camRot * Vector3.up; float num = Vector3.Dot(-camOffset, val3); float num2 = Vector3.Dot(-camOffset, val); float num3 = 0f; for (int i = 0; i < 2; i++) { float num4 = ((i == 0) ? (-1f) : 1f); Vector3 val4; Vector3 val5; if (ortho) { val4 = camOffset + val2 * (num4 * orthoSize * aspect) + val3 * num; val5 = val; } else { float num5 = Mathf.Tan(fov * 0.5f * ((float)Math.PI / 180f)); val4 = camOffset; Vector3 val6 = val + val2 * (num4 * num5 * aspect) + val3 * ((num2 > 0.1f) ? (num / num2) : 0f); val5 = ((Vector3)(ref val6)).normalized; } float num6 = num3; float num7; if (!(val5.y < -0.02f)) { num7 = 2000f; } else { Vector2 val7 = new Vector2(val4.x + val5.x * ((0f - val4.y) / val5.y), val4.z + val5.z * ((0f - val4.y) / val5.y)); num7 = ((Vector2)(ref val7)).magnitude; } num3 = num6 + num7; } return num3 * 0.5f; } public static float FarPlane(Vector3 cam, Vector3 player, float radius) { //IL_0000: 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_000d: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) Vector2 val = new Vector2(cam.x - player.x, cam.z - player.z); float magnitude = ((Vector2)(ref val)).magnitude; return radius + magnitude + Mathf.Max(0f, cam.y - player.y) + 5f; } } } namespace WanderNet { public static class Arcade { public static int SkippedSaves; public static int SkippedSteam; private static readonly Dictionary<string, ValueTuple<bool, int, float, string>> prefs = new Dictionary<string, ValueTuple<bool, int, float, string>>(); private static readonly string[] PrefKeys = new string[3] { "mostGold", "longestTime", "lastBiomeLoaded" }; [field: CompilerGenerated] public static bool On { [CompilerGenerated] get; [CompilerGenerated] private set; } public static void Enter(string why) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (On) { return; } On = true; SkippedSaves = 0; SkippedSteam = 0; prefs.Clear(); string[] prefKeys = PrefKeys; foreach (string text in prefKeys) { try { prefs[text] = new ValueTuple<bool, int, float, string>(PlayerPrefs.HasKey(text), PlayerPrefs.GetInt(text, 0), PlayerPrefs.GetFloat(text, 0f), PlayerPrefs.GetString(text, "")); } catch { } } Session.L("ARCADE ON (" + why + ") - nothing is saved or uploaded until you leave arcade"); Mod.Toast("ARCADE MODE - nothing is saved or uploaded. Press U for the creative menu.", 5f); Armory.UnlockAllNow(); Broadcast(); } public static void Exit(string why) { if (!On) { return; } On = false; RestorePrefs(); Creative.Close(); try { SaveLoad saveLoad = SaveLoad.saveLoad; if ((Object)(object)saveLoad != (Object)null) { saveLoad.Load(); } } catch (System.Exception ex) { Mod.Log.Warning("arcade: reloading the save: " + ex.Message); } Session.L($"ARCADE OFF ({why}) - skipped {SkippedSaves} save writes and {SkippedSteam} Steam stat/achievement calls; real save reloaded"); Broadcast(); } private static void RestorePrefs() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_008b: 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) Enumerator<string, ValueTuple<bool, int, float, string>> enumerator = prefs.GetEnumerator(); try { while (enumerator.MoveNext()) { KeyValuePair<string, ValueTuple<bool, int, float, string>> current = enumerator.Current; try { ValueTuple<bool, int, float, string> value = current.Value; if (!value.Item1) { PlayerPrefs.DeleteKey(current.Key); } else if (current.Key == "lastBiomeLoaded") { PlayerPrefs.SetString(current.Key, value.Item4); } else if (current.Key == "longestTime") { PlayerPrefs.SetFloat(current.Key, value.Item3); } else { PlayerPrefs.SetInt(current.Key, value.Item2); } } catch { } } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } try { PlayerPrefs.Save(); } catch { } } public static void OnQuit() { if (On) { RestorePrefs(); } } private static W Msg_() { W w = new W(Msg.ArcadeSet, 0); w.b.Write(On); return w; } public static void Broadcast() { try { if (Session.IsHost) { Session.Broadcast(Msg_().Bytes(), reliable: true, 255); } } catch { } } public static void SendTo(int peer) { try { byte[] array = Msg_().Bytes(); Net.Send(peer, reliable: true, array, array.Length); } catch { } } public static void Handle(R r) { if (r.b.ReadBoolean()) { Enter("the host is in arcade"); } else { Exit("the host left arcade"); } } } internal static class Arcade_SaveTargets { [CompilerGenerated] private sealed class <Of>d__0 : System.Collections.Generic.IEnumerable<MethodBase>, System.Collections.IEnumerable, System.Collections.Generic.IEnumerator<MethodBase>, System.IDisposable, System.Collections.IEnumerator { private int <>1__state; private MethodBase <>2__current; private int <>l__initialThreadId; private bool returnsBool; public bool <>3__returnsBool; private string[] <>7__wrap1; private int <>7__wrap2; private string <n>5__4; private MethodInfo[] <>7__wrap4; private int <>7__wrap5; MethodBase System.Collections.Generic.IEnumerator<MethodBase>.Current { [DebuggerHidden] get { return <>2__current; } } object System.Collections.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Of>d__0(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void System.IDisposable.Dispose() { } private bool MoveNext() { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; goto IL_011e; } <>1__state = -1; <>7__wrap1 = new string[12] { "TryWriteSave", "SaveThis", "Save", "RequestSave", "SaveRunCheckpoint", "EndRunWriteGateAndSave", "FlushRequestedSave", "ArchiveFileCopy", "ArchiveAndDeleteFile", "ArchiveCurrentSaveAndStartFresh", "MarkLegacyRootSaveHandled", "ArchiveRemainingLegacyRootFiles" }; <>7__wrap2 = 0; goto IL_0158; IL_012c: if (<>7__wrap5 < <>7__wrap4.Length) { MethodInfo val = <>7__wrap4[<>7__wrap5]; if (((MemberInfo)val).Name == <n>5__4 && val.ReturnType == typeof(bool) == returnsBool) { <>2__current = (MethodBase)(object)val; <>1__state = 1; return true; } goto IL_011e; } <>7__wrap4 = null; <n>5__4 = null; <>7__wrap2++; goto IL_0158; IL_011e: <>7__wrap5++; goto IL_012c; IL_0158: if (<>7__wrap2 < <>7__wrap1.Length) { <n>5__4 = <>7__wrap1[<>7__wrap2]; <>7__wrap4 = typeof(SaveLoad).GetMethods((BindingFlags)62); <>7__wrap5 = 0; goto IL_012c; } <>7__wrap1 = null; return false; } bool System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } [DebuggerHidden] System.Collections.Generic.IEnumerator<MethodBase> System.Collections.Generic.IEnumerable<MethodBase>.GetEnumerator() { <Of>d__0 <Of>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <Of>d__ = this; } else { <Of>d__ = new <Of>d__0(0); } <Of>d__.returnsBool = <>3__returnsBool; return <Of>d__; } [DebuggerHidden] System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return (System.Collections.IEnumerator)((System.Collections.Generic.IEnumerable<MethodBase>)this).GetEnumerator(); } } [IteratorStateMachine(typeof(<Of>d__0))] public static System.Collections.Generic.IEnumerable<MethodBase> Of(bool returnsBool) { string[] array = new string[12] { "TryWriteSave", "SaveThis", "Save", "RequestSave", "SaveRunCheckpoint", "EndRunWriteGateAndSave", "FlushRequestedSave", "ArchiveFileCopy", "ArchiveAndDeleteFile", "ArchiveCurrentSaveAndStartFresh", "MarkLegacyRootSaveHandled", "ArchiveRemainingLegacyRootFiles" }; foreach (string n in array) { MethodInfo[] methods = typeof(SaveLoad).GetMethods((BindingFlags)62); foreach (MethodInfo val in methods) { if (((MemberInfo)val).Name == n && val.ReturnType == typeof(bool) == returnsBool) { yield return (MethodBase)(object)val; } } } } public static void Note(MethodBase m) { Arcade.SkippedSaves++; if (Arcade.SkippedSaves == 1) { Session.L("Arcade: save write skipped (" + ((MemberInfo)m).Name + ") - arcade never touches your save"); } } } [HarmonyPatch] internal static class Arcade_NoSaveWritesBool { private static System.Collections.Generic.IEnumerable<MethodBase> TargetMethods() { return Arcade_SaveTargets.Of(returnsBool: true); } private static bool Prefix(MethodBase __originalMethod, ref bool __result) { if (!Arcade.On) { return true; } Arcade_SaveTargets.Note(__originalMethod); __result = true; return false; } } [HarmonyPatch] internal static class Arcade_NoSaveWritesVoid { private static System.Collections.Generic.IEnumerable<MethodBase> TargetMethods() { return Arcade_SaveTargets.Of(returnsBool: false); } private static bool Prefix(MethodBase __originalMethod) { if (!Arcade.On) { return true; } Arcade_SaveTargets.Note(__originalMethod); return false; } } public static class ArcadeAchievements { private static float t; public static void Tick() { if (Time.unscaledTime < t) { return; } t = Time.unscaledTime + 1f; try { System.Collections.Generic.IEnumerator<AchievementManager> enumerator = Object.FindObjectsOfType<AchievementManager>(true).GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { AchievementManager current = enumerator.Current; if ((Object)(object)current == (Object)null) { continue; } bool flag = !Arcade.On; if (((Behaviour)current).enabled != flag) { ((Behaviour)current).enabled = flag; if (!flag) { Arcade.SkippedSteam++; } } } } finally { ((System.IDisposable)enumerator)?.Dispose(); } } catch { } } } [HarmonyPatch(typeof(ArtifactSystem), "TrySpendReroll")] internal static class Arcade_InfiniteRerolls { private static bool Prefix(ref bool __result) { if (!Arcade.On) { return true; } __result = true; return false; } } [HarmonyPatch(typeof(ArtifactSystem), "GetRerollCount")] internal static class Arcade_RerollCount { private static void Postfix(ref int __result) { if (Arcade.On && __result < 99) { __result = 99; } } } public static class Armory { public sealed class Weapon { public string id; public string name; public GameObject prefab; public Sprite icon; public bool front; public bool side; public bool back; public bool top; public string Slots { get { List<string> val = new List<string>(); if (front) { val.Add("Front"); } if (side) { val.Add("Sides"); } if (back) { val.Add("Back"); } if (top) { val.Add("Top"); } return string.Join(" / ", (System.Collections.Generic.IEnumerable<string>)val); } } public bool Fits(int slot) { if (slot >= 0 && (slot != 0 || !front) && (slot != 1 || !side) && (slot != 2 || !back)) { if (slot == 3) { return top; } return false; } return true; } } public static readonly string[] SlotNames = new string[4] { "Front", "Sides", "Back", "Top" }; private static List<Weapon> catalogue; private static readonly Dictionary<int, string> baseAtTier = new Dictionary<int, string>(); private static string lastScene; private static Dictionary<string, GameObject> basePrefabs; private static int lastLogged; public static List<Weapon> Catalogue { get { Load(); return catalogue; } } private static bool IsWeapon(Module2 m) { if ((Object)(object)m != (Object)null) { if (!m.frontSlot && !m.sideSlot && !m.backSlot) { return m.topSlot; } return true; } return false; } private static string NameOf(Module2 m) { string text = null; try { text = m.moduleName; } catch { } if (string.IsNullOrWhiteSpace(text) || text.Contains("_")) { text = Clean(((Object)((Component)m).gameObject).name); } return text.Trim(); } public static string Clean(string n) { return (n ?? "").Replace("(Clone)", "").Trim(); } private static void Load() { //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) if (catalogue != null && catalogue.Count > 0) { return; } Dictionary<string, Weapon> byId = new Dictionary<string, Weapon>((IEqualityComparer<string>)(object)StringComparer.OrdinalIgnoreCase); try { ModuleSelection val = Object.FindObjectOfType<ModuleSelection>(); if ((Object)(object)val != (Object)null) { if (val.baseModulePrefabPool != null) { Enumerator<GameObject> enumerator = val.baseModulePrefabPool.GetEnumerator(); while (enumerator.MoveNext()) { Take(enumerator.Current); } } if (val.baseModulePrefabEternalPool != null) { Enumerator<GameObject> enumerator = val.baseModulePrefabEternalPool.GetEnumerator(); while (enumerator.MoveNext()) { Take(enumerator.Current); } } } } catch (System.Exception ex) { Mod.Log.Warning("armory pools: " + ex.Message); } int count = byId.Count; try { System.Collections.Generic.IEnumerator<Module2> enumerator2 = Resources.FindObjectsOfTypeAll<Module2>().GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator2).MoveNext()) { Module2 current = enumerator2.Current; if ((Object)(object)current != (Object)null) { Scene scene = ((Component)current).gameObject.scene; if (!((Scene)(ref scene)).IsValid()) { Take(((Component)current).gameObject); } } } } finally { ((System.IDisposable)enumerator2)?.Dispose(); } } catch { } catalogue = new List<Weapon>((System.Collections.Generic.IEnumerable<Weapon>)byId.Values); catalogue.Sort((Comparison<Weapon>)((Weapon a, Weapon b) => string.Compare(a.name, b.name, (StringComparison)5))); Mod.Log.Msg($"Creative menu: {catalogue.Count} weapons ({count} from the game's pick pools)"); [CompilerGenerated] void Take(GameObject go) { if (!((Object)(object)go == (Object)null)) { Module2 val2 = null; try { val2 = go.GetComponent<Module2>(); } catch { } if (IsWeapon(val2)) { string text = (string.IsNullOrEmpty(val2.moduleID) ? Clean(((Object)go).name) : val2.moduleID); if (!byId.ContainsKey(text)) { Sprite icon = null; try { icon = val2.displayImage; } catch { } byId[text] = new Weapon { id = text, name = NameOf(val2), prefab = go, icon = icon, front = val2.frontSlot, side = val2.sideSlot, back = val2.backSlot, top = val2.topSlot }; } } } } } public static List<Module2> Installed() { List<Module2> val = new List<Module2>(); VM val2 = (((Object)(object)GM.gm != (Object)null) ? GM.gm.vm : null); if ((Object)(object)val2 == (Object)null || val2.allModules2 == null) { return val; } Enumerator<Module2> enumerator = val2.allModules2.GetEnumerator(); while (enumerator.MoveNext()) { Module2 current = enumerator.Current; if (IsWeapon(current)) { val.Add(current); } } return val; } public static string IdOf(Module2 m) { if (!((Object)(object)m == (Object)null)) { if (!string.IsNullOrEmpty(m.moduleID)) { return m.moduleID; } return Clean(((Object)((Component)m).gameObject).name); } return ""; } public static string DisplayName(Module2 m) { return NameOf(m); } public static Sprite IconOf(Module2 m) { try { return m.displayImage; } catch { return null; } } public static string SlotsOf(Module2 m) { List<string> val = new List<string>(); if (m.frontSlot) { val.Add("Front"); } if (m.sideSlot) { val.Add("Sides"); } if (m.backSlot) { val.Add("Back"); } if (m.topSlot) { val.Add("Top"); } return string.Join(" / ", (System.Collections.Generic.IEnumerable<string>)val); } public static bool Has(string id) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) Enumerator<Module2> enumerator = Installed().GetEnumerator(); try { while (enumerator.MoveNext()) { if (IdOf(enumerator.Current) == id) { return true; } } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } return false; } public static string SlotSummary() { VM val = (((Object)(object)GM.gm != (Object)null) ? GM.gm.vm : null); if ((Object)(object)val == (Object)null) { return ""; } try { val.RebuildModuleSlotUsage(); return $"Slots used: Front {val.frontSlotsTaken}/{val.frontSlots} · Sides {val.sideSlotsTaken}/{val.sideSlots} · Back {val.backSlotsTaken}/{val.backSlots} · Top {val.topSlotsTaken}/{val.topSlots}"; } catch { return ""; } } public static void Remove(Module2 m) { VM val = (((Object)(object)GM.gm != (Object)null) ? GM.gm.vm : null); if ((Object)(object)m == (Object)null || (Object)(object)val == (Object)null) { return; } string text = NameOf(m); try { m.DeleteModule(); } catch (System.Exception ex) { Mod.Log.Warning("armory remove: " + ex.Message); } try { if (val.allModules2 != null && val.allModules2.Contains(m)) { val.allModules2.Remove(m); } } catch { } try { Object.Destroy((Object)(object)((Component)m).gameObject); } catch { } try { val.RebuildModuleSlotUsage(); } catch { } Session.L("Creative: removed weapon " + text); } public static string Add(Weapon w) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) VM val = (((Object)(object)GM.gm != (Object)null) ? GM.gm.vm : null); if (w == null || (Object)(object)val == (Object)null) { return "No castle right now."; } if (Has(w.id)) { return "You already have " + w.name + "."; } GameObject val2 = null; try { val2 = Object.Instantiate<GameObject>(w.prefab, ((Component)val).transform.position, Quaternion.identity); Module2 component = val2.GetComponent<Module2>(); val.RebuildModuleSlotUsage(); if (!val.HasFreeModuleSlot(component)) { Object.Destroy((Object)(object)val2); return "No free " + w.Slots + " slot. Click one of your weapons on the left first to swap it out."; } component.legendaryA = false; component.legendaryB = false; component.InstallModule(true, true); if (val.allModules2 == null || !val.allModules2.Contains(component)) { try { component.DeleteModule(); } catch { } Object.Destroy((Object)(object)val2); val.RebuildModuleSlotUsage(); return w.name + " could not be mounted on this castle."; } val.RebuildModuleSlotUsage(); Session.L($"Creative: added weapon {w.name} ({w.Slots})"); return null; } catch (System.Exception ex) { Mod.Log.Warning("armory add: " + (object)ex); if ((Object)(object)val2 != (Object)null) { try { Object.Destroy((Object)(object)val2); } catch { } } return w.name + " could not be added."; } } public static string Swap(Module2 old, Weapon w) { if ((Object)(object)old == (Object)null) { return Add(w); } if (w == null) { return "Pick a weapon."; } if (IdOf(old) == w.id) { return null; } if (Has(w.id)) { return "You already have " + w.name + "."; } if ((!old.frontSlot || !w.front) && (!old.sideSlot || !w.side) && (!old.backSlot || !w.back) && (!old.topSlot || !w.top)) { return $"{w.name} goes on {w.Slots}, {NameOf(old)} is on {SlotsOf(old)}. Pick a weapon for the same slot."; } Weapon weapon = FindPrefab(IdOf(old)); Remove(old); string text = Add(w); if (text != null && weapon != null) { Add(weapon); } return text; } private static Weapon FindPrefab(string id) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) Enumerator<Weapon> enumerator = Catalogue.GetEnumerator(); try { while (enumerator.MoveNext()) { Weapon current = enumerator.Current; if (current.id == id) { return current; } } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } return null; } public static void Track() { GM gm = GM.gm; VM val = (((Object)(object)gm != (Object)null) ? gm.vm : null); if (Sync.Scene != lastScene) { lastScene = Sync.Scene; baseAtTier.Clear(); } if ((Object)(object)val == (Object)null || (Object)(object)val.vp == (Object)null) { return; } try { baseAtTier[gm.currentTier] = Clean(((Object)((Component)val.vp).gameObject).name); } catch { } } private static GameObject BasePrefab(string name) { //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) if (basePrefabs == null || basePrefabs.Count == 0) { basePrefabs = new Dictionary<string, GameObject>((IEqualityComparer<string>)(object)StringComparer.OrdinalIgnoreCase); try { System.Collections.Generic.IEnumerator<VP> enumerator = Resources.FindObjectsOfTypeAll<VP>().GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { VP current = enumerator.Current; if ((Object)(object)current != (Object)null) { Scene scene = ((Component)current).gameObject.scene; if (!((Scene)(ref scene)).IsValid() && !basePrefabs.ContainsKey(((Object)((Component)current).gameObject).name)) { basePrefabs[((Object)((Component)current).gameObject).name] = ((Component)current).gameObject; } } } } finally { ((System.IDisposable)enumerator)?.Dispose(); } } catch { } } GameObject result = default(GameObject); if (name == null || !basePrefabs.TryGetValue(name, ref result)) { return null; } return result; } private static List<GameObject> TierList(ModuleSelection ms, int tier) { List<GameObject> val = new List<GameObject>(); List<GameObject> val2 = null; try { val2 = (List<GameObject>)(tier switch { 5 => ms.vehicleBasesPrefabsTier5, 4 => ms.vehicleBasesPrefabsTier4, 3 => ms.vehicleBasesPrefabsTier3, 2 => ms.vehicleBasesPrefabsTier2, _ => null, }); } catch { } if (val2 != null) { Enumerator<GameObject> enumerator = val2.GetEnumerator(); while (enumerator.MoveNext()) { GameObject current = enumerator.Current; if ((Object)(object)current != (Object)null) { val.Add(current); } } } return val; } public static string Down() { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) GM gm = GM.gm; VM val = (((Object)(object)gm != (Object)null) ? gm.vm : null); if ((Object)(object)val == (Object)null || (Object)(object)val.vp == (Object)null) { return "No castle right now."; } int currentTier = gm.currentTier; int num = currentTier - 1; int num2 = ((baseAtTier.Count > 0) ? 2147483647 : 0); Enumerator<int, string> enumerator = baseAtTier.Keys.GetEnumerator(); try { while (enumerator.MoveNext()) { int current = enumerator.Current; num2 = Math.Min(num2, current); } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } if (num < num2 || num < 0) { return "Your castle is already at its smallest size."; } GameObject val2 = null; string name = default(string); if (baseAtTier.TryGetValue(num, ref name)) { val2 = BasePrefab(name); } ModuleSelection val3 = Object.FindObjectOfType<ModuleSelection>(); if ((Object)(object)val2 == (Object)null && (Object)(object)val3 != (Object)null) { List<GameObject> val4 = TierList(val3, num); if (val4.Count > 0) { val2 = val4[0]; } } if ((Object)(object)val2 == (Object)null && (Object)(object)gm.startVP != (Object)null) { val2 = BasePrefab(Clean(((Object)((Component)gm.startVP).gameObject).name)); } if ((Object)(object)val2 == (Object)null) { return "Couldn't find the smaller castle for this run."; } string text = ApplyBase(val2, val3); if (text != null) { return text; } gm.currentTier = num; Session.L($"Creative: castle tier {currentTier} -> {num} ({Clean(((Object)val2).name)})"); return null; } private static string ApplyBase(GameObject prefab, ModuleSelection ms) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) GM gm = GM.gm; VM vm = gm.vm; GameObject val = null; try { val = Object.Instantiate<GameObject>(prefab, Vector3.zero, Quaternion.identity); VP component = val.GetComponent<VP>(); if ((Object)(object)component == (Object)null) { Object.Destroy((Object)(object)val); return "That castle base is broken."; } Transform val2 = (((Object)(object)ms != (Object)null) ? ((Component)ms).transform : ((Component)vm).transform.parent); List<Module2> obj = VehicleModuleTransfer.DetachInstalledModules(vm, val2, new Il2CppReferenceArray<Module2>(0L)); component.ApplyVehicleBase(false, 0, true); if ((Object)(object)ms != (Object)null) { ms.vm = gm.vm; } VehicleModuleTransfer.MountModulesOnCurrentVehicle(obj, true); List<Module2> allModules = gm.vm.allModules2; if (allModules != null) { Enumerator<Module2> enumerator = allModules.GetEnumerator(); while (enumerator.MoveNext()) { Module2 current = enumerator.Current; if ((Object)(object)current != (Object)null) { try { current.UpgradeModuleSize(); } catch { } } } } try { component.ActivateSpawnEffect(); } catch { } try { gm.vm.UnblockCoinCollection(); } catch { } return null; } catch (System.Exception ex) { Mod.Log.Warning("armory castle: " + (object)ex); return "Changing the castle failed - see the log."; } } public static void UnlockAll(SaveGame s) { if (s == null || !Arcade.On) { return; } int num = 0; int num2 = 0; try { if (s.unlockedIDs == null) { s.unlockedIDs = new List<int>(); } HashSet<int> val = new HashSet<int>(); Enumerator<int> enumerator = s.unlockedIDs.GetEnumerator(); while (enumerator.MoveNext()) { int current = enumerator.Current; val.Add(current); } System.Collections.Generic.IEnumerator<Unlockable> enumerator2 = Resources.FindObjectsOfTypeAll<Unlockable>().GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator2).MoveNext()) { Unlockable current2 = enumerator2.Current; if (!((Object)(object)current2 == (Object)null)) { int unlockableID = current2.unlockableID; if (unlockableID != 0 && !val.Contains(unlockableID)) { val.Add(unlockableID); s.unlockedIDs.Add(unlockableID); num++; } } } } finally { ((System.IDisposable)enumerator2)?.Dispose(); } } catch (System.Exception ex) { Mod.Log.Warning("arcade unlocks: " + ex.Message); } try { if (s.unlockedBiomeIDs == null) { s.unlockedBiomeIDs = new List<string>(); } HashSet<string> val2 = new HashSet<string>(); Enumerator<string> enumerator3 = s.unlockedBiomeIDs.GetEnumerator(); while (enumerator3.MoveNext()) { string current3 = enumerator3.Current; val2.Add(current3); } System.Collections.Generic.IEnumerator<BiomeData> enumerator4 = Resources.FindObjectsOfTypeAll<BiomeData>().GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator4).MoveNext()) { BiomeData current4 = enumerator4.Current; if (!((Object)(object)current4 == (Object)null) && !string.IsNullOrEmpty(current4.biomeID) && !val2.Contains(current4.biomeID)) { val2.Add(current4.biomeID); s.unlockedBiomeIDs.Add(current4.biomeID); num2++; } } } finally { ((System.IDisposable)enumerator4)?.Dispose(); } } catch (System.Exception ex2) { Mod.Log.Warning("arcade zones: " + ex2.Message); } int num3 = s.unlockedIDs.Count + s.unlockedBiomeIDs.Count; if (num + num2 > 0 && num3 != lastLogged) { lastLogged = num3; Session.L($"Arcade: everything unlocked for this session, not saved ({s.unlockedIDs.Count} items, {s.unlockedBiomeIDs.Count} zones)"); } } public static void UnlockAllNow() { try { SaveLoad saveLoad = SaveLoad.saveLoad; if ((Object)(object)saveLoad != (Object)null) { UnlockAll(saveLoad.saveGame); } } catch { } } } [HarmonyPatch(typeof(SaveLoad), "Load")] internal static class Arcade_UnlockOnLoad { private static void Postfix(SaveLoad __instance) { if (Arcade.On) { try { Armory.UnlockAll(__instance.saveGame); } catch { } } } } [HarmonyPatch(typeof(Loadout), "OnEnable")] internal static class Arcade_UnlockOnLoadout { private static void Prefix() { if (Arcade.On) { Armory.UnlockAllNow(); } } } public static class BigMap { [HarmonyPatch(typeof(MapGenerator), "BuildValidSpawnerSnapshot")] private static class Patch_Spread { private static void Prefix() { if (!Wanted || Applied || Sync.Scene != "MAIN SCENE") { return; } Applied = true; try { Spread(); } catch (System.Exception ex) { Mod.Log.Warning("big map: " + (object)ex); } } } [HarmonyPatch(typeof(Loadout), "Go")] private static class Patch_WaitForMap { private static bool Prefix() { if (releasing || !Applied || !Session.IsHost || !StillBuilding) { return true; } if (!queuedGo) { queuedGo = true; Session.L("Start pressed while the big map is still being built - starting as soon as it's ready"); } Mod.Toast("Building the big map... the run starts as soon as it's ready", 3f); return false; } } public static float Area = 1f; public static float VoxelX = 3f; public static bool Applied; public static int Added; public static int Grounds; public static int Walls; private static float genT0; private static bool genLogged; private static MapGenerator mg; private static bool queuedGo; private static bool releasing; public static float Scale => Mathf.Sqrt(Area); public static bool Enabled => Area > 1.01f; private static bool Wanted { get { if (Enabled) { return GameModes.IsEndless; } return false; } } public static bool StillBuilding { get { try { if ((Object)(object)mg == (Object)null || ((Il2CppObjectBase)mg).WasCollected) { mg = Object.FindObjectOfType<MapGenerator>(); } return (Object)(object)mg != (Object)null && mg.generationRunning; } catch { return false; } } } public static void OnSceneLoaded() { queuedGo = false; Applied = false; Added = 0; Grounds = 0; genT0 = Time.realtimeSinceStartup; genLogged = false; } public static void WatchGeneration() { if (genLogged || Sync.Scene != "MAIN SCENE") { return; } if ((Object)(object)mg == (Object)null || ((Il2CppObjectBase)mg).WasCollected) { mg = Object.FindObjectOfType<MapGenerator>(); if ((Object)(object)mg == (Object)null) { return; } } if (!mg.generationRunning) { genLogged = true; Session.L($"Map generated in {Time.realtimeSinceStartup - genT0:0.0} s (big={Applied}, navmesh ok={mg.navMeshBuildSucceeded})"); } } private static void Spread() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_05a4: Unknown result type (might be due to invalid IL or missing references) //IL_05a9: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_04b5: Unknown result type (might be due to invalid IL or missing references) //IL_04ba: Unknown result type (might be due to invalid IL or missing references) //IL_04be: Unknown result type (might be due to invalid IL or missing references) //IL_04cb: Unknown result type (might be due to invalid IL or missing references) //IL_04d2: Unknown result type (might be due to invalid IL or missing references) //IL_04df: Unknown result type (might be due to invalid IL or missing references) //IL_04eb: Unknown result type (might be due to invalid IL or missing references) //IL_04f0: Unknown result type (might be due to invalid IL or missing references) //IL_04f4: Unknown result type (might be due to invalid IL or missing references) //IL_0501: Unknown result type (might be due to invalid IL or missing references) //IL_0508: Unknown result type (might be due to invalid IL or missing references) //IL_0515: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: 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_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0307: 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_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0323: 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_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Unknown result type (might be due to invalid IL or missing references) List<PrefabSpawner> spawners = MapGenerator.spawners; if (spawners == null) { return; } List<PrefabSpawner> val = new List<PrefabSpawner>(); for (int i = 0; i < spawners.Count; i++) { PrefabSpawner val2 = spawners[i]; if ((Object)(object)val2 != (Object)null && !((Il2CppObjectBase)val2).WasCollected) { val.Add(val2); } } if (val.Count == 0) { return; } List<float> val3 = new List<float>(); Enumerator<PrefabSpawner> enumerator = val.GetEnumerator(); try { while (enumerator.MoveNext()) { PrefabSpawner current = enumerator.Current; float num = 3.4028235E+38f; Vector3 position = ((Component)current).transform.position; Enumerator<PrefabSpawner> enumerator2 = val.GetEnumerator(); try { while (enumerator2.MoveNext()) { PrefabSpawner current2 = enumerator2.Current; if (!((Object)(object)current == (Object)(object)current2)) { Vector3 val4 = ((Component)current2).transform.position - position; val4.y = 0f; float magnitude = ((Vector3)(ref val4)).magnitude; if (magnitude > 1f && magnitude < num) { num = magnitude; } } } } finally { ((System.IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose(); } if (num < 3.4028235E+38f) { val3.Add(num); } } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } val3.Sort(); float num2 = ((val3.Count > 0) ? val3[val3.Count / 2] : 60f); num2 = Mathf.Clamp(num2, 20f, 200f); float num3 = 500f * Scale * 0.97f; int num4 = Mathf.CeilToInt(Scale - 0.01f); float num5 = num2 * Scale / (float)num4; int num6 = Mathf.Max(0, Mathf.RoundToInt(Area) - 1); List<Vector3> val5 = new List<Vector3>(); for (int j = 0; j < num4; j++) { for (int k = 0; k < num4; k++) { if (j != 0 || k != 0) { val5.Add(new Vector3((float)j * num5, 0f, (float)k * num5)); } } } List<Vector3> val6 = new List<Vector3>(); for (int l = 0; l < num6; l++) { if (val5.Count <= 0) { break; } val6.Add(val5[Mathf.Min(val5.Count - 1, l * val5.Count / num6)]); } enumerator = val.GetEnumerator(); try { Vector3 val7 = default(Vector3); Vector3 val8 = default(Vector3); while (enumerator.MoveNext()) { PrefabSpawner current3 = enumerator.Current; Transform transform = ((Component)current3).transform; Vector3 position2 = transform.position; ((Vector3)(ref val7))..ctor(position2.x * Scale, position2.y, position2.z * Scale); transform.position = val7; Enumerator<Vector3> enumerator3 = val6.GetEnumerator(); try { while (enumerator3.MoveNext()) { Vector3 current4 = enumerator3.Current; ((Vector3)(ref val8))..ctor(val7.x, 0f, val7.z); float num7 = ((((Vector3)(ref val8)).sqrMagnitude > 1f) ? (Mathf.Atan2(val8.x, val8.z) * 57.29578f) : 0f); Vector3 val9 = val7 + Quaternion.Euler(0f, num7, 0f) * current4; Vector2 val10 = new Vector2(val9.x, val9.z); if (!(((Vector2)(ref val10)).magnitude > num3)) { PrefabSpawner component = Object.Instantiate<GameObject>(((Component)current3).gameObject, val9, transform.rotation, transform.parent).GetComponent<PrefabSpawner>(); if ((Object)(object)component != (Object)null && !spawners.Contains(component)) { spawners.Add(component); Added++; } } } } finally { ((System.IDisposable)enumerator3/*cast due to .constrained prefix*/).Dispose(); } } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } System.Collections.Generic.IEnumerator<Renderer> enumerator4 = Object.FindObjectsOfType<Renderer>().GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator4).MoveNext()) { Renderer current5 = enumerator4.Current; if (!((Object)(object)current5 == (Object)null)) { string name = ((Object)((Component)current5).gameObject).name; if (name.StartsWith("BaseGround") || name == "MainFog") { ((Component)current5).transform.localScale = ((Component)current5).transform.localScale * Scale; Grounds++; } } } } finally { ((System.IDisposable)enumerator4)?.Dispose(); } try { if ((Object)(object)GM.gm != (Object)null) { GM.gm.mapSize = 500f * Scale; } } catch { } Walls = 0; try { System.Collections.Generic.IEnumerator<Transform> enumerator5 = Object.FindObjectsOfType<Transform>().GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator5).MoveNext()) { Transform current6 = enumerator5.Current; if (!((Object)(object)current6 == (Object)null) && !(((Object)current6).name != "Corner_Boxcollider")) { Vector3 position3 = current6.position; current6.position = new Vector3(position3.x * Scale, position3.y, position3.z * Scale); Vector3 localScale = current6.localScale; current6.localScale = new Vector3(localScale.x * Scale, localScale.y, localScale.z * Scale); Walls += ((Component)current6).GetComponentsInChildren<Collider>(true).Length; } } } finally { ((System.IDisposable)enumerator5)?.Dispose(); } } catch (System.Exception ex) { Mod.Log.Warning("map walls: " + ex.Message); } try { MapGenerator val11 = Object.FindObjectOfType<MapGenerator>(); NavMeshSurface val12 = (((Object)(object)val11 != (Object)null) ? val11.navmesh : null); if ((Object)(object)val12 != (Object)null) { NavMeshBuildSettings settingsByID = NavMesh.GetSettingsByID(val12.agentTypeID); float num8 = (val12.overrideVoxelSize ? val12.voxelSize : ((NavMeshBuildSettings)(ref settingsByID)).voxelSize); val12.overrideVoxelSize = true; val12.voxelSize = num8 * VoxelX; Session.L($"Survival map: navmesh detail {num8:0.000} -> {val12.voxelSize:0.000} m"); } } catch (System.Exception ex2) { Mod.Log.Warning("navmesh detail: " + ex2.Message); } Session.L($"Survival map: {Area:0.#}x area ({Scale:0.00}x wide), {val.Count} chunk spots spread out, {Added} added (gap {num2:0} m), {Grounds} ground planes scaled, {Walls} edge walls moved out, edge {500f * Scale:0} m"); } private static void ReleaseGo() { if (!queuedGo || StillBuilding) { return; } queuedGo = false; Loadout val = Object.FindObjectOfType<Loadout>(); if ((Object)(object)val == (Object)null) { return; } releasing = true; try { val.Go(); Session.L("Big map ready - starting the run"); } catch (System.Exception ex) { Mod.Log.Warning("start after map: " + ex.Message); } finally { releasing = false; } } public static void Tick() { try { WatchGeneration(); ReleaseGo(); } catch { } if (!Applied || !Wanted) { return; } try { GM gm = GM.gm; if ((Object)(object)gm != (Object)null && gm.mapSize < 500f * Scale - 1f) { gm.mapSize = 500f * Scale; } } catch { } } } public static class BotFx { private class Bolt { public GameObject go; public Vector3 a; public Vector3 b; public float t0; public float dur; } public static int Drawn; private static readonly List<Bolt> bolts = new List<Bolt>(); private static Material boltMat; private static float matLookT; private static readonly MaterialPropertyBlock mpb = new MaterialPropertyBlock(); public static void Shot(byte bot, Vector3 from, Vector3 to) { //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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) Draw(bot, from, to); W w = new W(Msg.BotShot, bot); w.V3(from); w.V3(to); Session.Broadcast(w.Bytes(), reliable: false, 255, inRunOnly: true); } public static void Handle(byte from, R r) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = r.V3(); Vector3 to = r.V3(); RemotePlayer remotePlayer = default(RemotePlayer); if (Session.Players.TryGetValue(from, ref remotePlayer) && (Object)(object)remotePlayer.ghost != (Object)null) { val = remotePlayer.ghost.transform.position; } Draw(from, val, to); } private static Material FindMat(byte bot) { //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown if ((Object)(object)boltMat != (Object)null) { return boltMat; } if (Time.unscaledTime < matLookT) { return null; } matLookT = Time.unscaledTime + 3f; try { GameObject val = null; RemotePlayer remotePlayer = default(RemotePlayer); if (Session.Players.TryGetValue(bot, ref remotePlayer) && (Object)(object)remotePlayer.ghost != (Object)null) { val = remotePlayer.ghost; } if ((Object)(object)val == (Object)null && (Object)(object)GM.gm != (Object)null && (Object)(object)GM.gm.vm != (Object)null) { val = ((Component)GM.gm.vm).gameObject; } if ((Object)(object)val != (Object)null) { System.Collections.Generic.IEnumerator<MeshRenderer> enumerator = val.GetComponentsInChildren<MeshRenderer>(true).GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { Material sharedMaterial = ((Renderer)enumerator.Current).sharedMaterial; if ((Object)(object)sharedMaterial != (Object)null && (Object)(object)sharedMaterial.shader != (Object)null) { boltMat = new Material(sharedMaterial); break; } } } finally { ((System.IDisposable)enumerator)?.Dispose(); } } } catch { } return boltMat; } private static void Draw(byte bot, Vector3 from, Vector3 to) { //IL_00f7: 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_0191: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: 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_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) if (Sync.Scene != "MAIN SCENE") { return; } Material val = FindMat(bot); if ((Object)(object)val == (Object)null) { return; } Bolt bolt = null; Enumerator<Bolt> enumerator = bolts.GetEnumerator(); try { while (enumerator.MoveNext()) { Bolt current = enumerator.Current; if ((Object)(object)current.go != (Object)null && !current.go.activeSelf) { bolt = current; break; } } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } if (bolt == null) { if (bolts.Count >= 80) { return; } GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)val2).name = "WN_BotShot"; Object.DontDestroyOnLoad((Object)(object)val2); try { Collider component = val2.GetComponent<Collider>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } } catch { } MeshRenderer component2 = val2.GetComponent<MeshRenderer>(); ((Renderer)component2).sharedMaterial = val; ((Renderer)component2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component2).receiveShadows = false; val2.transform.localScale = new Vector3(0.6f, 0.6f, 2.6f); bolt = new Bolt { go = val2 }; bolts.Add(bolt); } Color val3 = Color.Lerp(Session.ColorOf(bot), Color.white, 0.35f); try { MeshRenderer component3 = bolt.go.GetComponent<MeshRenderer>(); ((Renderer)component3).GetPropertyBlock(mpb); mpb.SetColor("_BaseColor", val3); mpb.SetColor("_Color", val3); mpb.SetColor("_EmissionColor", val3 * 2f); ((Renderer)component3).SetPropertyBlock(mpb); } catch { } bolt.a = from + Vector3.up * 4f; bolt.b = to + Vector3.up * 1.5f; float num = Vector3.Distance(bolt.a, bolt.b); bolt.dur = Mathf.Clamp(num / 70f, 0.12f, 0.5f); bolt.t0 = Time.unscaledTime; bolt.go.transform.position = bolt.a; bolt.go.SetActive(true); Drawn++; } public static void Tick() { //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_007e: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00c4: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_011b: 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_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: 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_0177: Unknown result type (might be due to invalid IL or missing references) float unscaledTime = Time.unscaledTime; bool flag = Sync.Scene == "MAIN SCENE"; Enumerator<Bolt> enumerator = bolts.GetEnumerator(); try { while (enumerator.MoveNext()) { Bolt current = enumerator.Current; if ((Object)(object)current.go == (Object)null || !current.go.activeSelf) { continue; } float num = (unscaledTime - current.t0) / current.dur; if (num >= 1f || !flag) { current.go.SetActive(false); continue; } Vector3 val = Vector3.Lerp(current.a, current.b, num) + Vector3.up * (Mathf.Sin(num * (float)Math.PI) * Mathf.Min(6f, Vector3.Distance(current.a, current.b) * 0.12f)); Vector3 val2 = Vector3.Lerp(current.a, current.b, Mathf.Min(1f, num + 0.05f)) + Vector3.up * (Mathf.Sin(Mathf.Min(1f, num + 0.05f) * (float)Math.PI) * Mathf.Min(6f, Vector3.Distance(current.a, current.b) * 0.12f)); current.go.transform.position = val; Vector3 val3 = val2 - val; if (((Vector3)(ref val3)).sqrMagnitude > 0.0001f) { current.go.transform.rotation = Quaternion.LookRotation(val3); } } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } } } public sealed class LegRig { private const float StepTime = 0.28f; private const float SendInterval = 0.1f; private readonly byte id; private GameObject inst; private readonly List<Transform> partTs; private readonly List<int> legParts = new List<int>(); private readonly List<FastIKFabric> legs = new List<FastIKFabric>(); private Vector3[] foot; private Vector3[] from; private Vector3[] to; private float[] stepT; private int[] group; private Vector3[] apos; private Quaternion[] arot; private float stepLen = 5f; private float lift = 2f; private float sendT; private float lastT; private Vector3 lastPos; private bool placed; public static int Rigs; public static int Sends; public static Transform RootOf(FastIKFabric f) { try { if ((Object)(object)f.Root != (Object)null) { return f.Root; } } catch { } Transform val = ((Component)f).transform; for (int i = 0; i < f.ChainLength + 1; i++) { if (!((Object)(object)val.parent != (Object)null)) { break; } val = val.parent; } return val; } private LegRig(byte id, GameObject inst, List<Transform> partTs) { this.id = id; this.inst = inst; this.partTs = partTs; } public static LegRig Make(byte id, GameObject inst, List<Transform> partTs) { //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)inst == (Object)null || partTs == null) { return null; } Il2CppArrayBase<FastIKFabric> componentsInChildren = inst.GetComponentsInChildren<FastIKFabric>(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { return null; } LegRig legRig = new LegRig(id, inst, partTs); System.Collections.Generic.IEnumerator<FastIKFabric> enumerator = componentsInChildren.GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { FastIKFabric current = enumerator.Current; if ((Object)(object)current != (Object)null && (Object)(object)current.Target != (Object)null && (Object)(object)current.defaulRootPosition != (Object)null) { legRig.legs.Add(current); } } } finally { ((System.IDisposable)enumerator)?.Dispose(); } if (legRig.legs.Count == 0) { return null; } try { SpiderLegController2 componentInChildren = inst.GetComponentInChildren<SpiderLegController2>(true); if ((Object)(object)componentInChildren != (Object)null && componentInChildren.stepLength > 0.5f) { legRig.stepLen = componentInChildren.stepLength; } } catch { } legRig.lift = Mathf.Clamp(legRig.stepLen * 0.4f, 1.5f, 4f); List<Transform> val = new List<Transform>(); Enumerator<FastIKFabric> enumerator2 = legRig.legs.GetEnumerator(); try { while (enumerator2.MoveNext()) { FastIKFabric current2 = enumerator2.Current; Transform val2 = ((Component)current2).transform; for (int i = 0; i < current2.ChainLength + 1; i++) { if (!((Object)(object)val2.parent != (Object)null)) { break; } val2 = val2.parent; } val.Add(val2); } } finally { ((System.IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose(); } for (int j = 0; j < partTs.Count; j++) { Transform val3 = partTs[j]; if ((Object)(object)val3 == (Object)null) { continue; } Enumerator<Transform> enumerator3 = val.GetEnumerator(); try { while (enumerator3.MoveNext()) { Transform current3 = enumerator3.Current; if (val3.IsChildOf(current3)) { legRig.legParts.Add(j); break; } } } finally { ((System.IDisposable)enumerator3/*cast due to .constrained prefix*/).Dispose(); } } int count = legRig.legs.Count; legRig.foot = (Vector3[])(object)new Vector3[count]; legRig.from = (Vector3[])(object)new Vector3[count]; legRig.to = (Vector3[])(object)new Vector3[count]; legRig.stepT = new float[count]; legRig.group = new int[count]; for (int k = 0; k < count; k++) { Vector3 val4 = inst.transform.InverseTransformPoint(legRig.legs[k].defaulRootPosition.position); legRig.group[k] = ((val4.x < 0f != val4.z < 0f) ? 1 : 0); legRig.stepT[k] = -1f; } legRig.apos = (Vector3[])(object)new Vector3[partTs.Count]; legRig.arot = (Quaternion[])(object)new Quaternion[partTs.Count]; Rigs++; return legRig; } public void Dispose() { if ((Object)(object)inst != (Object)null) { try { Object.Destroy((Object)(object)inst); } catch { } inst = null; } } public void Tick(Transform ghost, float now) { //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028a: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02be: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: 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_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_035a: 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_0364: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)inst == (Object)null || (Object)(object)ghost == (Object)null) { return; } float num = ((lastT > 0f) ? Mathf.Clamp(now - lastT, 0f, 0.1f) : 0f); lastT = now; if (Time.timeScale < 0.01f) { num = 0f; } inst.transform.SetPositionAndRotation(ghost.position, ghost.rotation); Vector3 val = ((num > 0f) ? ((ghost.position - lastPos) / Mathf.Max(num, 0.001f)) : Vector3.zero); val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude > 900f) { val = Vector3.zero; } lastPos = ghost.position; int count = legs.Count; if (!placed) { for (int i = 0; i < count; i++) { foot[i] = legs[i].defaulRootPosition.position; } placed = true; } float[] array = new float[2]; bool flag = false; Vector3 val2; for (int j = 0; j < count; j++) { if (stepT[j] >= 0f) { flag = true; } Vector3 position = legs[j].defaulRootPosition.position; position.y = foot[j].y; int num2 = group[j]; float num3 = array[group[j]]; val2 = foot[j] - position; array[num2] = Mathf.Max(num3, ((Vector3)(ref val2)).magnitude); } int num4 = ((!(array[0] >= array[1])) ? 1 : 0); for (int k = 0; k < count; k++) { Vector3 position2 = legs[k].defaulRootPosition.position; if (stepT[k] >= 0f) { stepT[k] += num / 0.28f; float num5 = Mathf.Clamp01(stepT[k]); float num6 = num5 * num5 * (3f - 2f * num5); foot[k] = Vector3.Lerp(from[k], to[k], num6) + Vector3.up * (Mathf.Sin(num5 * (float)Math.PI) * lift); if (num5 >= 1f) { stepT[k] = -1f; foot[k] = to[k]; } } else if (!flag && group[k] == num4) { Vector3 val3 = foot[k