using System; using System.CodeDom.Compiler; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using ExitGames.Client.Photon; using HarmonyLib; using ImGuiNET; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Peak.Network; using Photon.Pun; using Photon.Realtime; using PhotonCustomPropsUtils; using Sirenix.Serialization; using Steamworks; using TerrainCustomiser.Managers; using TerrainCustomiser.Map; using TerrainCustomiser.Map.Serialization; using TerrainCustomiser.Session; using TerrainCustomiser.TerrainGeneration; using TerrainCustomiser.UI; using TerrainCustomiser.UI.Modals; using TerrainCustomiser.UI.Windows; using TerrainCustomiser.Utils; using Unity.Burst; using Unity.Collections; using Unity.Jobs; using Unity.Mathematics; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using Zorro.Core; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: RegisterFormatter(typeof(GameObjectFormatter), 10)] [assembly: RegisterFormatter(typeof(MaterialFormatter), 10)] [assembly: RegisterFormatter(typeof(TransformFormatter), 10)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("TerrainCustomiser")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+9fc5873ba288ee7e573cba4abe314dcc4eaa331f")] [assembly: AssemblyProduct("TerrainCustomiser")] [assembly: AssemblyTitle("TerrainCustomiser")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } public sealed class GameObjectFormatter : MinimalBaseFormatter { protected override void Read(ref GameObject value, IDataReader reader) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown string text = default(string); string kv = default(string); while ((int)reader.PeekEntry(ref text) != 8) { reader.ReadString(ref kv); if (text == "name") { GameObject val = TerrainCustomiser.Map.ResourceManager.GameObjectResources.Find((GameObject x) => ((Object)x).name == kv); value = val; } else if (text == "targetId") { GameObject val2 = new GameObject(kv); val2.SetActive(false); value = val2; MapSerializer.testgos.Add(val2); } else { reader.SkipEntry(); } } } protected override void Write(ref GameObject value, IDataWriter writer) { GameObject go = value.gameObject; KeyValuePair keyValuePair = MapSerializer.GameObjectReferences.FirstOrDefault>((KeyValuePair x) => (Object)(object)x.Value == (Object)(object)go); if ((Object)(object)keyValuePair.Value == (Object)null) { writer.WriteString("name", ((Object)value).name); } else { writer.WriteString("targetId", keyValuePair.Key); } } } public sealed class MaterialFormatter : MinimalBaseFormatter { protected override void Read(ref Material value, IDataReader reader) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 string text = default(string); string kv = default(string); while ((int)reader.PeekEntry(ref text) != 8) { reader.ReadString(ref kv); if (text == "name") { Material val = TerrainCustomiser.Map.ResourceManager.MaterialResources.Find((Material x) => (Object)(object)x != (Object)null && ((Object)x).name == kv); value = val; } else { reader.SkipEntry(); } } } protected override void Write(ref Material value, IDataWriter writer) { writer.WriteString("name", ((Object)value).name); } } public sealed class TransformFormatter : MinimalBaseFormatter { protected override void Read(ref Transform value, IDataReader reader) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown string text = default(string); string text2 = default(string); while ((int)reader.PeekEntry(ref text) != 8) { reader.ReadString(ref text2); if (text == "refid") { GameObject val = new GameObject(text2); val.SetActive(false); value = val.transform; MapSerializer.testgos.Add(val); } else if (text == "refpath") { GameObject val2 = GameObject.Find(text2); if ((Object)(object)val2 != (Object)null) { value = val2.transform; } else { value = null; } } else { reader.SkipEntry(); } } } protected override void Write(ref Transform value, IDataWriter writer) { GameObject go = ((Component)value).gameObject; KeyValuePair keyValuePair = MapSerializer.GameObjectReferences.FirstOrDefault>((KeyValuePair x) => (Object)(object)x.Value == (Object)(object)go); if ((Object)(object)keyValuePair.Value == (Object)null) { string pathFromGameObject = MapSerializer.GetPathFromGameObject(go); writer.WriteString("refpath", pathFromGameObject); } else { writer.WriteString("refid", keyValuePair.Key); } } } namespace TerrainCustomiser { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.snosz.terraincustomiser", "TerrainCustomiser", "0.3.2")] public class Plugin : BaseUnityPlugin { public static Plugin Instance; private static Harmony _harmony; private void Awake() { Instance = this; ConfigManager.Setup(); BundleManager.Setup(); PlayerInfoManager.Setup(); WindowsManager.Setup(); _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); } private void OnDestroy() { _harmony.UnpatchSelf(); BundleManager.UnloadAll(); Object.Destroy((Object)(object)Singleton.Instance); } public void LoadWilIsland() { AirportCheckInKiosk val = Object.FindFirstObjectByType(); if ((Object)(object)val == (Object)null) { Debug.LogError((object)"[TC] Failed to find airportkiosk"); return; } int ascentIndex = GUIManager.instance.boardingPass.ascentIndex; ((MonoBehaviourPun)val).photonView.RPC("BeginIslandLoadRPC", (RpcTarget)0, new object[3] { "WilIsland", ascentIndex, RunSettings.GetSerializedRunSettings() }); } } [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")] [DebuggerNonUserCode] [CompilerGenerated] internal class Resource1 { private static System.Resources.ResourceManager resourceMan; private static CultureInfo resourceCulture; [EditorBrowsable(EditorBrowsableState.Advanced)] internal static System.Resources.ResourceManager ResourceManager { get { if (resourceMan == null) { System.Resources.ResourceManager resourceManager = new System.Resources.ResourceManager("TerrainCustomiser.Resource1", typeof(Resource1).Assembly); resourceMan = resourceManager; } return resourceMan; } } [EditorBrowsable(EditorBrowsableState.Advanced)] internal static CultureInfo Culture { get { return resourceCulture; } set { resourceCulture = value; } } internal static byte[] selectionoverlay { get { object @object = ResourceManager.GetObject("selectionoverlay", resourceCulture); return (byte[])@object; } } internal static byte[] visibilitycompute { get { object @object = ResourceManager.GetObject("visibilitycompute", resourceCulture); return (byte[])@object; } } internal Resource1() { } } } namespace TerrainCustomiser.Utils { public class DebugVisualiser : MonoBehaviour { private abstract class Shape { public Color color; public float duration; public float startTime; private int startFrame; public bool alwaysOnTop; public bool Expired => (duration <= 0f) ? (Time.frameCount > startFrame) : (Time.time - startTime > duration); protected Shape(Color color, float duration, bool alwaysOnTop) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) this.color = color; this.duration = duration; this.alwaysOnTop = alwaysOnTop; startTime = Time.time; startFrame = Time.frameCount; } public abstract void Draw(); } private class MeshShape : Shape { private Mesh mesh; private Transform transform; public MeshShape(Mesh mesh, Transform transform, Color color, float duration, bool alwaysOnTop) : base(color, duration, alwaysOnTop) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) this.mesh = mesh; this.transform = transform; } public override void Draw() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)mesh == (Object)null) && !((Object)(object)transform == (Object)null)) { Vector3[] vertices = mesh.vertices; int[] triangles = mesh.triangles; for (int i = 0; i < triangles.Length; i += 3) { int num = triangles[i]; int num2 = triangles[i + 1]; int num3 = triangles[i + 2]; Vector3 val = transform.TransformPoint(vertices[num]); Vector3 val2 = transform.TransformPoint(vertices[num2]); Vector3 val3 = transform.TransformPoint(vertices[num3]); GL.Color(color); GL.Vertex(val); GL.Vertex(val2); GL.Vertex(val2); GL.Vertex(val3); GL.Vertex(val3); GL.Vertex(val); } } } } private class BoxShape : Shape { private Vector3 center; private Vector3 size; private Quaternion rotation; public BoxShape(Vector3 center, Vector3 size, Quaternion rotation, Color color, float duration, bool alwaysOnTop) : base(color, duration, alwaysOnTop) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) this.center = center; this.size = size; this.rotation = rotation; } public override void Draw() { //IL_0002: 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_0011: 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_0021: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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_010a: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_017d: 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) Vector3 val = size * 0.5f; Vector3[] array = (Vector3[])(object)new Vector3[8] { new Vector3(0f - val.x, 0f - val.y, 0f - val.z), new Vector3(val.x, 0f - val.y, 0f - val.z), new Vector3(val.x, 0f - val.y, val.z), new Vector3(0f - val.x, 0f - val.y, val.z), new Vector3(0f - val.x, val.y, 0f - val.z), new Vector3(val.x, val.y, 0f - val.z), new Vector3(val.x, val.y, val.z), new Vector3(0f - val.x, val.y, val.z) }; for (int i = 0; i < array.Length; i++) { array[i] = center + rotation * array[i]; } int[,] array2 = new int[12, 2] { { 0, 1 }, { 1, 2 }, { 2, 3 }, { 3, 0 }, { 4, 5 }, { 5, 6 }, { 6, 7 }, { 7, 4 }, { 0, 4 }, { 1, 5 }, { 2, 6 }, { 3, 7 } }; GL.Color(color); for (int j = 0; j < array2.GetLength(0); j++) { GL.Vertex(array[array2[j, 0]]); GL.Vertex(array[array2[j, 1]]); } } } private class RayShape : Shape { private Vector3 from; private Vector3 dir; public RayShape(Vector3 from, Vector3 dir, Color color, float duration, bool alwaysOnTop) : base(color, duration, alwaysOnTop) { //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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) this.from = from; this.dir = dir; } public override void Draw() { //IL_0002: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) GL.Color(color); GL.Vertex(from); GL.Vertex(from + dir); } } private class LineShape : Shape { private Vector3 from; private Vector3 to; public LineShape(Vector3 from, Vector3 to, Color color, float duration, bool alwaysOnTop) : base(color, duration, alwaysOnTop) { //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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) this.from = from; this.to = to; } public override void Draw() { //IL_0002: 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_001a: Unknown result type (might be due to invalid IL or missing references) GL.Color(color); GL.Vertex(from); GL.Vertex(to); } } private class SphereShape : Shape { private Vector3 pos; private float radius; public SphereShape(Vector3 pos, float radius, Color color, float duration, bool alwaysOnTop) : base(color, duration, alwaysOnTop) { //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) this.pos = pos; this.radius = radius; } public override void Draw() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_009a: 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_00c1: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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_0106: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0138: 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_0142: 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_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0172: 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) int num = 24; for (int i = 0; i < num; i++) { float num2 = (float)i / (float)num * MathF.PI * 2f; float num3 = (float)(i + 1) / (float)num * MathF.PI * 2f; Vector3 val = pos + new Vector3(Mathf.Cos(num2), 0f, Mathf.Sin(num2)) * radius; Vector3 val2 = pos + new Vector3(Mathf.Cos(num3), 0f, Mathf.Sin(num3)) * radius; GL.Color(color); GL.Vertex(val); GL.Vertex(val2); Vector3 val3 = pos + new Vector3(0f, Mathf.Cos(num2), Mathf.Sin(num2)) * radius; Vector3 val4 = pos + new Vector3(0f, Mathf.Cos(num3), Mathf.Sin(num3)) * radius; GL.Vertex(val3); GL.Vertex(val4); Vector3 val5 = pos + new Vector3(Mathf.Cos(num2), Mathf.Sin(num2), 0f) * radius; Vector3 val6 = pos + new Vector3(Mathf.Cos(num3), Mathf.Sin(num3), 0f) * radius; GL.Vertex(val5); GL.Vertex(val6); } } } private static DebugVisualiser _instance; private List _shapes = new List(); private Material lineMaterialNormal; private Material lineMaterialOverlay; private void Awake() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown if ((Object)(object)_instance == (Object)null) { _instance = this; } else { Object.Destroy((Object)(object)((Component)this).gameObject); } lineMaterialNormal = new Material(Shader.Find("Hidden/Internal-Colored")); lineMaterialOverlay = new Material(Shader.Find("Hidden/Internal-Colored")); lineMaterialOverlay.SetInt("_ZTest", 8); RenderPipelineManager.endCameraRendering += OnEndCameraRendering; } private void OnDisable() { RenderPipelineManager.endCameraRendering -= OnEndCameraRendering; } private void OnEndCameraRendering(ScriptableRenderContext ctx, Camera cam) { if (_shapes.Count != 0) { DrawShapes(overlay: false, lineMaterialNormal); DrawShapes(overlay: true, lineMaterialOverlay); } } public static void DrawRay(Vector3 from, Vector3 dir, Color color, float duration = 0f, bool alwaysOnTop = false) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_instance == (Object)null) { CreateInstance(); } _instance._shapes.Add(new RayShape(from, dir, color, duration, alwaysOnTop)); } public static void DrawSphere(Vector3 pos, float radius, Color color, float duration = 0f, bool alwaysOnTop = false) { //IL_0020: 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) if ((Object)(object)_instance == (Object)null) { CreateInstance(); } _instance._shapes.Add(new SphereShape(pos, radius, color, duration, alwaysOnTop)); } public static void DrawLine(Vector3 from, Vector3 to, Color color, float duration = 0f, bool alwaysOnTop = false) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_instance == (Object)null) { CreateInstance(); } _instance._shapes.Add(new LineShape(from, to, color, duration, alwaysOnTop)); } public static void DrawBox(Vector3 center, Vector3 size, Color color, float duration = 0f, bool alwaysOnTop = false) { //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_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) DrawBox(center, size, Quaternion.identity, color, duration, alwaysOnTop); } public static void DrawBox(Vector3 center, Vector3 size, Quaternion rotation, Color color, float duration = 0f, bool alwaysOnTop = false) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_instance == (Object)null) { CreateInstance(); } _instance._shapes.Add(new BoxShape(center, size, rotation, color, duration, alwaysOnTop)); } public static void DrawMeshCollider(MeshCollider collider, Color color, float duration = 0f, bool alwaysOnTop = false) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)collider == (Object)null) && !((Object)(object)collider.sharedMesh == (Object)null)) { if ((Object)(object)_instance == (Object)null) { CreateInstance(); } _instance._shapes.Add(new MeshShape(collider.sharedMesh, ((Component)collider).transform, color, duration, alwaysOnTop)); } } private static void CreateInstance() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown GameObject val = new GameObject("TC_DebugVisualiser"); ((Object)val).hideFlags = (HideFlags)61; _instance = val.AddComponent(); } private void DrawShapes(bool overlay, Material mat) { mat.SetPass(0); GL.Begin(1); for (int num = _shapes.Count - 1; num >= 0; num--) { if (_shapes[num].Expired) { _shapes.RemoveAt(num); } else if (_shapes[num].alwaysOnTop == overlay) { _shapes[num].Draw(); } } GL.End(); } } public static class GizmoUtils { public class RendererMaterialCache { public Renderer Renderer; public Material[] OriginalMaterials; public Material OverlayMaterial; } internal static Shader SelectionOverlayShader; public static void TryDrawGizmos(Transform target, Component component) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_0055: 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_007b: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_00e1: 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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) if (component is PropSpawner) { PropSpawner val = (PropSpawner)component; DrawPropSpawnerGizmos(component.transform, val.area, val.rayLength, val.rayNearCutoff); } else if (component is PropSpawner_Line) { PropSpawner_Line val2 = (PropSpawner_Line)component; Vector3 to = ((Component)val2).transform.position + val2.height * 0.5f * ((Component)val2).transform.up; DebugVisualiser.DrawLine(((Component)val2).transform.position - val2.height * 0.5f * ((Component)val2).transform.up, to, Color.white); } else if (component is PropSpawner_Sphere) { PropSpawner_Sphere val3 = (PropSpawner_Sphere)component; DebugVisualiser.DrawSphere(((Component)val3).transform.position, val3.rayLength, Color.white); } else if (component is SpecialDayZone) { SpecialDayZone val4 = (SpecialDayZone)component; DebugVisualiser.DrawBox(((Component)val4).transform.position, ((Bounds)(ref val4.bounds)).size, Color.white); } } public static void TryDrawOverlays(Transform target) { } public static void TryRestoreMaterials() { } public static void DrawPropSpawnerGizmos(Transform target, Vector2 area, float rayLength, float rayNearCutoff) { //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_0014: 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_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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b3: 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) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: 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_011e: 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_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0131: 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_0141: 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_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_015b: 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_0166: 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_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0188: 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_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: 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_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: 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_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_01e8: 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_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: 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_020c: 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_020f: 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_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0233: 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_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) Vector3 val = target.position + area.y * 0.5f * target.up; Vector3 val2 = target.position - area.y * 0.5f * target.up; Vector3 val3 = target.position - area.x * 0.5f * target.right; Vector3 val4 = target.position + area.x * 0.5f * target.right; DebugVisualiser.DrawLine(val2, val, Color.white); DebugVisualiser.DrawLine(val3, val4, Color.white); DebugVisualiser.DrawLine(val2, val2 + target.forward * rayLength + target.forward * rayNearCutoff, Color.green); DebugVisualiser.DrawLine(val, val + target.forward * rayLength + target.forward * rayNearCutoff, Color.green); DebugVisualiser.DrawLine(val3, val3 + target.forward * rayLength + target.forward * rayNearCutoff, Color.green); DebugVisualiser.DrawLine(val4, val4 + target.forward * rayLength + target.forward * rayNearCutoff, Color.green); DebugVisualiser.DrawBox(target.position + target.forward * rayLength / 2f, Vector3.one, target.rotation, Color.green); DebugVisualiser.DrawLine(val2, val2 + target.forward * rayNearCutoff, Color.red); DebugVisualiser.DrawLine(val3, val3 + target.forward * rayNearCutoff, Color.red); DebugVisualiser.DrawLine(val, val + target.forward * rayNearCutoff, Color.red); DebugVisualiser.DrawLine(val4, val4 + target.forward * rayNearCutoff, Color.red); } public static List GetRenderersFromObject(GameObject target) { //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_0055: Unknown result type (might be due to invalid IL or missing references) List list = new List(); LODGroup[] componentsInChildren = target.GetComponentsInChildren(true); if (componentsInChildren != null && componentsInChildren.Length != 0) { LODGroup[] array = componentsInChildren; foreach (LODGroup val in array) { LOD[] lODs = val.GetLODs(); LOD[] array2 = lODs; foreach (LOD val2 in array2) { Renderer[] renderers = val2.renderers; foreach (Renderer val3 in renderers) { if (!((Object)(object)val3 == (Object)null)) { list.Add(val3); } } } } return list; } return target.GetComponentsInChildren(true).ToList(); } public static List ApplyOverlayToRenderers(List renderers) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown List list = new List(); foreach (Renderer renderer in renderers) { Material[] sharedMaterials = renderer.sharedMaterials; Material val = new Material(SelectionOverlayShader); list.Add(new RendererMaterialCache { Renderer = renderer, OriginalMaterials = sharedMaterials, OverlayMaterial = val }); Material[] array = (Material[])(object)new Material[sharedMaterials.Length + 1]; Array.Copy(sharedMaterials, array, sharedMaterials.Length); array[^1] = val; renderer.sharedMaterials = array; } return list; } public static List ApplyOverlayToRenderers(Renderer[] renderers) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown List list = new List(); foreach (Renderer val in renderers) { Material[] sharedMaterials = val.sharedMaterials; Material val2 = new Material(SelectionOverlayShader); list.Add(new RendererMaterialCache { Renderer = val, OriginalMaterials = sharedMaterials, OverlayMaterial = val2 }); Material[] array = (Material[])(object)new Material[sharedMaterials.Length + 1]; Array.Copy(sharedMaterials, array, sharedMaterials.Length); array[^1] = val2; val.sharedMaterials = array; } return list; } public static void RestoreRendererMaterials(List rendererCache) { foreach (RendererMaterialCache item in rendererCache) { if (!((Object)(object)item.Renderer == (Object)null)) { item.Renderer.sharedMaterials = item.OriginalMaterials; if ((Object)(object)item.OverlayMaterial != (Object)null) { Object.Destroy((Object)(object)item.OverlayMaterial); } } } rendererCache.Clear(); } } public static class NetworkUtils { public static byte[] CompressBrotli(byte[] data) { using MemoryStream memoryStream = new MemoryStream(); using (BrotliStream brotliStream = new BrotliStream(memoryStream, CompressionLevel.Optimal)) { brotliStream.Write(data, 0, data.Length); } return memoryStream.ToArray(); } public static byte[] DecompressBrotli(byte[] compressed) { using MemoryStream stream = new MemoryStream(compressed); using BrotliStream brotliStream = new BrotliStream(stream, CompressionMode.Decompress); using MemoryStream memoryStream = new MemoryStream(); brotliStream.CopyTo(memoryStream); return memoryStream.ToArray(); } public static byte[] SerializeMapSyncData(MapSerializer.MapSyncData data) { string s = JsonConvert.SerializeObject((object)data); return Encoding.UTF8.GetBytes(s); } public static MapSerializer.MapSyncData DeserializeMapSyncData(byte[] bytes) { string @string = Encoding.UTF8.GetString(bytes); return JsonConvert.DeserializeObject(@string); } public static byte[] CompressMapSyncData(MapSerializer.MapSyncData data) { byte[] data2 = SerializeMapSyncData(data); return CompressBrotli(data2); } public static MapSerializer.MapSyncData DecompressMapSyncData(byte[] compressed) { byte[] bytes = DecompressBrotli(compressed); return DeserializeMapSyncData(bytes); } public static void SetMapDataRoomProperty(MapSerializer.MapSyncData mapSyncData) { byte[] array = CompressMapSyncData(mapSyncData); double num = (double)array.Length / 1048576.0; Debug.Log((object)$"Compressed MapSyncData Size: {num:F2} MB"); NetworkManager.SetRoomProperty("mapData", array); } } } namespace TerrainCustomiser.UI { public static class ContextMenu { private static int selectedItemIndex = -1; private static Type[] types; public static void GetTypes(Type type) { types = GetConcreteDerivedTypes(type); } public static void CreateMenu(IList list, Type type) { if (!ImGui.BeginPopupContextItem("WidgetContextMenu")) { return; } for (int i = 0; i < types.Length; i++) { if (ImGui.Selectable(types[i].Name)) { object value = Activator.CreateInstance(types[i]); list.Add(value); types = null; break; } } ImGui.EndPopup(); } private static Type[] GetConcreteDerivedTypes(Type baseType) { Type baseType2 = baseType; return (from t in AppDomain.CurrentDomain.GetAssemblies().SelectMany((Assembly a) => a.GetTypes()) where baseType2.IsAssignableFrom(t) && !t.IsAbstract && !t.IsInterface select t).ToArray(); } } public static class EditorGizmos { public static bool IsEnabled = false; private static List rendererMaterialCache = new List(); private static Transform Target; public static void ToggleGizmos() { IsEnabled = !IsEnabled; if (!IsEnabled) { GizmoUtils.RestoreRendererMaterials(rendererMaterialCache); } else { RefreshGizmos(); } } public static void OnSelectionChanged(Transform selected) { Target = selected; if (IsEnabled) { GizmoUtils.RestoreRendererMaterials(rendererMaterialCache); LevelGenStep component = ((Component)Target).gameObject.GetComponent(); GizmoUtils.TryDrawGizmos(Target, (Component)(object)component); if ((Object)(object)component != (Object)null) { Renderer[] componentsInChildren = ((Component)Target).gameObject.GetComponentsInChildren(true); rendererMaterialCache = GizmoUtils.ApplyOverlayToRenderers(componentsInChildren); } } } public static void RefreshGizmos() { if (!IsEnabled) { return; } GizmoUtils.RestoreRendererMaterials(rendererMaterialCache); if (!((Object)(object)Target == (Object)null)) { LevelGenStep component = ((Component)Target).gameObject.GetComponent(); GizmoUtils.TryDrawGizmos(Target, (Component)(object)component); if ((Object)(object)component != (Object)null) { Renderer[] componentsInChildren = ((Component)Target).gameObject.GetComponentsInChildren(true); rendererMaterialCache = GizmoUtils.ApplyOverlayToRenderers(componentsInChildren); } } } } public class HierarchyView { public class ContextNode { public string Name; public List Children = new List(); public Action Action; public Func CanUseNode; public void AddContextItem(string label, Action action, Func canUseNode) { Children.Add(new ContextNode { Name = label, Action = action, CanUseNode = canUseNode }); } } public Action OnSelectionChanged; public Func ShouldDrawNode; public List ContextNodes = new List(); public Transform Selected { get; private set; } public void DrawNode(Transform t) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)t == (Object)null || (ShouldDrawNode != null && !ShouldDrawNode(t))) { return; } ImGuiTreeNodeFlags val = (ImGuiTreeNodeFlags)4288; if ((Object)(object)Selected == (Object)(object)t) { val = (ImGuiTreeNodeFlags)(val | 1); } ImGui.PushID(((Object)t).GetInstanceID()); if (t.childCount == 0) { val = (ImGuiTreeNodeFlags)(val | 0x100); } bool flag = ImGui.TreeNodeEx("", val, ((Object)t).name); if (ImGui.IsItemClicked() || ImGui.IsItemClicked((ImGuiMouseButton)1)) { SetSelected(t); } if (ImGui.IsItemClicked((ImGuiMouseButton)1)) { ImGui.OpenPopup("HierarchyItemContextMenuPopup"); } if (ImGui.BeginPopup("HierarchyItemContextMenuPopup")) { DrawContextNodes(t); ImGui.EndPopup(); } if (flag) { for (int i = 0; i < t.childCount; i++) { DrawNode(t.GetChild(i)); } ImGui.TreePop(); } ImGui.PopID(); } public void SetSelected(Transform t) { if (!((Object)(object)Selected == (Object)(object)t)) { Selected = t; OnSelectionChanged?.Invoke(t); } } public ContextNode AddContextMenu(string label, Func canUseNode) { ContextNode contextNode = new ContextNode { Name = label, CanUseNode = canUseNode }; ContextNodes.Add(contextNode); return contextNode; } public void AddContextItem(string label, Action action, Func canUseNode) { ContextNodes.Add(new ContextNode { Name = label, Action = action, CanUseNode = canUseNode }); } public void DrawContextNodes(Transform t) { foreach (ContextNode contextNode in ContextNodes) { bool flag = true; if (contextNode.CanUseNode != null) { flag = contextNode.CanUseNode(t); } if (!flag) { ImGui.BeginDisabled(); } DrawContextNode(contextNode, t); if (!flag) { ImGui.EndDisabled(); } } } private void DrawContextNode(ContextNode node, Transform t) { if (node.Children.Count > 0) { DrawMenuNode(node, t); } else { DrawMenuItemNode(node, t); } } private void DrawMenuItemNode(ContextNode node, Transform t) { if (ImGui.MenuItem(node.Name)) { node.Action?.Invoke(t); } } private void DrawMenuNode(ContextNode node, Transform t) { if (!ImGui.BeginMenu(node.Name)) { return; } foreach (ContextNode child in node.Children) { DrawContextNode(child, t); } ImGui.EndMenu(); } } public static class ImGuiHelpers { public static void DrawPropertiesTable(string tableName, WidgetFactory.FieldWidgetData[] fieldWidgets) { if (!ImGui.BeginTable("Table_" + tableName, 2)) { return; } ImGui.TableSetupColumn("Name", (ImGuiTableColumnFlags)16, 100f); ImGui.TableSetupColumn("Value", (ImGuiTableColumnFlags)8); foreach (WidgetFactory.FieldWidgetData fieldWidgetData in fieldWidgets) { if (!fieldWidgetData.IsHidden) { if (fieldWidgetData.IsDisabled) { ImGui.BeginDisabled(); } ImGui.TableNextColumn(); ImGui.TextUnformatted(fieldWidgetData.Name); ImGui.TableNextColumn(); ImGui.SetNextItemWidth(-1f); fieldWidgetData.Draw(); ImGui.TableNextRow(); if (fieldWidgetData.IsDisabled) { ImGui.EndDisabled(); } } } ImGui.EndTable(); } public static void DrawFullLayoutField(WidgetFactory.FieldWidgetData fieldWidget) { if (!fieldWidget.IsHidden) { ImGui.SetNextItemWidth(-1f); if (fieldWidget.IsDisabled) { ImGui.BeginDisabled(); } WidgetFactory.DrawField(fieldWidget); if (fieldWidget.IsDisabled) { ImGui.EndDisabled(); } } } public static void DrawButton(string label, Action onClick, bool enabled = true) { if (!enabled) { ImGui.BeginDisabled(); } if (ImGui.Button(label)) { onClick(); } if (!enabled) { ImGui.EndDisabled(); } } public static void DrawSmallButton(string label, Action onClick, bool enabled = true) { if (!enabled) { ImGui.BeginDisabled(); } if (ImGui.SmallButton(label)) { onClick(); } if (!enabled) { ImGui.EndDisabled(); } } } public static class WidgetFactory { public class FieldWidgetData { public string Name; public Type Type; public Func Get; public Action Set; public RangeAttribute RangeAttribute = null; public bool IsHidden = false; public bool IsDisabled = false; public FieldWidgetData(Type type, Func get, Action set, string name, RangeAttribute rangeAttribute = null, bool isHidden = false, bool isDisabled = false) { Type = type; Get = get; Set = set; Name = name; RangeAttribute = rangeAttribute; IsHidden = isHidden; IsDisabled = isDisabled; } public FieldWidgetData() { } public FieldWidgetData(FieldData fieldData, object ownerObject) { FieldData fieldData2 = fieldData; object ownerObject2 = ownerObject; base..ctor(); Type = fieldData2.fieldInfo.FieldType; Get = () => fieldData2.fieldInfo.GetValue(ownerObject2); Set = delegate(object v) { fieldData2.fieldInfo.SetValue(ownerObject2, v); }; Name = fieldData2.name; RangeAttribute = fieldData2.rangeAttribute; IsHidden = fieldData2.widgetMode == WidgetMode.Hidden; IsDisabled = fieldData2.widgetMode == WidgetMode.Disabled; } public virtual void Draw() { DrawField(Type, Get, Set, Name, RangeAttribute); } } public class ComboWidgetData : FieldWidgetData { public Func GetIndex; public Action SetIndex; public Func GetOptions; public ComboWidgetData(string name, Func getIndex, Action setIndex, Func getOptions) { Name = name; GetIndex = getIndex; SetIndex = setIndex; GetOptions = getOptions; } public override void Draw() { int num = GetIndex(); string[] array = GetOptions(); if (array != null && array.Length != 0) { if (num < 0 || num >= array.Length) { num = 0; } ImGui.PushID(Name); if (ImGui.Combo("##v", ref num, array, array.Length)) { SetIndex(num); } ImGui.PopID(); } } } public class FieldData { public string name; public FieldInfo fieldInfo; public RangeAttribute rangeAttribute; public FieldLayout layout; public WidgetMode widgetMode; } public enum WidgetMode { Default, Disabled, Hidden } public enum FieldLayout { Inline, Full } private static List spawnerHideFieldData = new List { "_deferredSteps", "validationConstraints", "_propSpawnData", "_madeDummyData", "k__BackingField", "k__BackingField" }; public static Dictionary TypeFieldDataDictionary = new Dictionary(); public static void DrawField(object obj, FieldData fieldData) { object obj2 = obj; FieldInfo f = fieldData.fieldInfo; DrawField(f.FieldType, () => f.GetValue(obj2), delegate(object v) { f.SetValue(obj2, v); }, f.Name, fieldData.rangeAttribute); } public static void DrawField(FieldWidgetData fieldWidgetData) { DrawField(fieldWidgetData.Type, fieldWidgetData.Get, fieldWidgetData.Set, fieldWidgetData.Name, fieldWidgetData.RangeAttribute); } public static void DrawField(Type t, Func get, Action set, string id, RangeAttribute rangeAttribute = null) { Func get2 = get; Action set2 = set; ImGui.PushID(id); if (t == typeof(int)) { DrawInt(() => (int)get2(), delegate(int v) { set2(v); }); } else if (t == typeof(float)) { if (rangeAttribute != null) { DrawSliderFloat(() => (float)get2(), delegate(float v) { set2(v); }, rangeAttribute.min, rangeAttribute.max); } else { DrawFloat(() => (float)get2(), delegate(float v) { set2(v); }); } } else if (t == typeof(string)) { DrawString(() => (string)get2(), delegate(string v) { set2(v); }); } else if (t == typeof(Vector2)) { DrawVector2(() => (Vector2)get2(), delegate(Vector2 v) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) set2(v); }); } else if (t == typeof(Vector2Int)) { DrawVector2Int(() => (Vector2Int)get2(), delegate(Vector2Int v) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) set2(v); }); } else if (t == typeof(Vector3)) { DrawVector3(() => (Vector3)get2(), delegate(Vector3 v) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) set2(v); }); } else if (t == typeof(Vector3Int)) { DrawVector3Int(() => (Vector3Int)get2(), delegate(Vector3Int v) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) set2(v); }); } else if (t == typeof(Vector4)) { DrawVector4(() => (Vector4)get2(), delegate(Vector4 v) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) set2(v); }); } else if (t == typeof(Bounds)) { DrawBounds(() => (Bounds)get2(), delegate(Bounds v) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) set2(v); }); } else if (t == typeof(bool)) { DrawBool(() => (bool)get2(), delegate(bool v) { set2(v); }); } else if (t.IsEnum) { DrawEnum(() => (Enum)get2(), delegate(Enum v) { set2(v); }); } else if (t == typeof(Color)) { DrawColor(() => (Color)get2(), delegate(Color v) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) set2(v); }); } else if (t == typeof(GameObject)) { DrawGameObject(() => (GameObject)get2(), delegate(GameObject v) { set2(v); }); } else if (t == typeof(Material)) { DrawMaterial(() => (Material)get2(), delegate(Material v) { set2(v); }); } else if (t == typeof(Transform)) { DrawTransform(() => (Transform)get2(), delegate(Transform v) { set2(v); }); } else if (t.IsArray) { DrawArray(t.GetElementType(), () => (Array)get2(), delegate(Array a) { set2(a); }, id); } else if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(List<>)) { DrawList(t.GetGenericArguments()[0], () => (IList)get2(), id); } else if (t.IsClass && !typeof(Object).IsAssignableFrom(t)) { DrawClass(get2, set2, t); } else { ImGui.TextDisabled(t.ToString() + " NYI"); } ImGui.PopID(); } private static void DrawClass(Func get, Action set, Type classType) { object obj = get(); if (obj == null) { if (ImGui.SmallButton("Create")) { obj = Activator.CreateInstance(classType); set(obj); } return; } Type type = obj.GetType(); if (ImGui.TreeNode(obj.GetType().Name)) { List list = new List(); FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { FieldWidgetData item = new FieldWidgetData(GetFieldData(fieldInfo), obj); list.Add(item); } ImGuiHelpers.DrawPropertiesTable(obj.GetType().Name, list.ToArray()); ImGui.TreePop(); } } private static void DrawInt(Func get, Action set) { int obj = get(); if (ImGui.InputInt("##v", ref obj)) { set(obj); } } private static void DrawFloat(Func get, Action set) { float obj = get(); if (ImGui.InputFloat("##v", ref obj)) { set(obj); } } private static void DrawString(Func get, Action set) { string text = get(); if (text == null) { text = ""; } if (ImGui.InputText("##v", ref text, 32u)) { set(text); } } private static void DrawSliderFloat(Func get, Action set, float min, float max) { float obj = get(); if (ImGui.SliderFloat("##v", ref obj, min, max)) { set(obj); } } private static void DrawVector2(Func get, Action set) { //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_0019: Unknown result type (might be due to invalid IL or missing references) Vector2 obj = get(); if (ImGui.InputFloat2("##v", ref obj)) { set(obj); } } private static void DrawVector2Int(Func get, Action set) { //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_0040: Unknown result type (might be due to invalid IL or missing references) Vector2Int val = get(); int[] array = new int[2] { ((Vector2Int)(ref val)).x, ((Vector2Int)(ref val)).y }; if (ImGui.InputInt2("##v", ref array[0])) { set(new Vector2Int(array[0], array[1])); } } public static void DrawVector3(Func get, Action set) { //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_0019: Unknown result type (might be due to invalid IL or missing references) Vector3 obj = get(); if (ImGui.InputFloat3("##v", ref obj)) { set(obj); } } private static void DrawVector3Int(Func get, Action set) { //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_004d: Unknown result type (might be due to invalid IL or missing references) Vector3Int val = get(); int[] array = new int[3] { ((Vector3Int)(ref val)).x, ((Vector3Int)(ref val)).y, ((Vector3Int)(ref val)).z }; if (ImGui.InputInt3("##v", ref array[0])) { set(new Vector3Int(array[0], array[1], array[2])); } } public static void DrawVector4(Func get, Action set) { //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_0019: Unknown result type (might be due to invalid IL or missing references) Vector4 obj = get(); if (ImGui.InputFloat4("##v", ref obj)) { set(obj); } } public static void DrawBounds(Func get, Action set) { //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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0047: 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_0088: 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) Bounds obj = get(); Vector3 center = ((Bounds)(ref obj)).center; Vector3 extents = ((Bounds)(ref obj)).extents; ImGui.TextUnformatted("Center"); ImGui.SameLine(); ImGui.SetNextItemWidth(-1f); if (ImGui.InputFloat3("##vc", ref center)) { ((Bounds)(ref obj)).center = center; set(obj); } ImGui.TextUnformatted("Extent"); ImGui.SameLine(); ImGui.SetNextItemWidth(-1f); if (ImGui.InputFloat3("##ve", ref extents)) { ((Bounds)(ref obj)).extents = extents; set(obj); } } private static void DrawBool(Func get, Action set) { bool obj = get(); if (ImGui.Checkbox("##v", ref obj)) { set(obj); } } private static void DrawEnum(Func get, Action set) { Enum @enum = get(); int value = Convert.ToInt32(@enum); Type type = @enum.GetType(); Array values = Enum.GetValues(type); string[] names = Enum.GetNames(type); if (ImGui.Combo("##v", ref value, names, names.Length)) { set((Enum)Enum.ToObject(type, value)); } } public static void DrawCombo(int selectedIndex, Func get, Action set) { string[] array = get(); if (ImGui.Combo("##v", ref selectedIndex, array, array.Length)) { set(selectedIndex); } } private static void DrawColor(Func get, Action set) { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Vector4 val = Color.op_Implicit(get()); if (ImGui.ColorEdit4("##v", ref val)) { set(Color.op_Implicit(val)); } } private static void DrawGameObject(Func get, Action set) { GameObject val = get(); string text = (((Object)(object)val != (Object)null) ? ((Object)val).name : "None"); ImGui.TextUnformatted(text); ImGui.SameLine(); if (ImGui.SmallButton("Change")) { ResourceWindow.Show(get, set); WindowsManager.Get().Open(); } } public static void DrawMaterial(Func get, Action set) { Material val = get(); string text = (((Object)(object)val != (Object)null) ? ((Object)val).name : "None"); ImGui.TextUnformatted(text); ImGui.SameLine(); if (ImGui.SmallButton("Change")) { ResourceWindow.Show(get, set); WindowsManager.Get().Open(); } } private static void DrawTransform(Func get, Action set) { Transform val = get(); string text = (((Object)(object)val != (Object)null) ? ((Object)val).name : "None"); ImGui.SetNextItemAllowOverlap(); if (ImGui.Selectable(text)) { } ImGui.SameLine(); if (ImGui.SmallButton("Change")) { ResourceWindow.Show(get, set); WindowsManager.Get().Open(); } } private static void DrawArray(Type elementType, Func get, Action set, string name) { Array array = get(); if (array == null) { ImGui.TextUnformatted(name); ImGui.SameLine(); if (ImGui.SmallButton("Create")) { array = Array.CreateInstance(elementType, 0); set(array); } return; } int num = -1; if (ImGui.TreeNode("Array", $"{name} [{array.Length}]")) { for (int i = 0; i < array.Length; i++) { ImGui.PushID(i); int index = i; DrawField(elementType, () => array.GetValue(index), delegate(object v) { array.SetValue(v, index); }, index.ToString()); ImGui.SameLine(); ImGui.PushID("Remove"); if (ImGui.SmallButton("Remove")) { num = index; } ImGui.PopID(); ImGui.PopID(); } if (ImGui.SmallButton("Add")) { AddElement(array, set); } ImGui.TreePop(); } if (num >= 0) { RemoveAt(array, set, num); num = -1; } } private static void DrawList(Type elementType, Func get, string name) { IList list = get(); if (list == null) { ImGui.TextUnformatted(name); ImGui.SameLine(); if (ImGui.SmallButton("Create")) { Type type = typeof(List<>).MakeGenericType(elementType); list = (IList)Activator.CreateInstance(type); } return; } int num = -1; if (ImGui.TreeNode("List", $"{name} [{list.Count}]")) { for (int i = 0; i < list.Count; i++) { ImGui.PushID(i); int index = i; DrawField(elementType, () => list[index], delegate(object v) { list[index] = v; }, index.ToString()); ImGui.SameLine(); ImGui.PushID("Remove"); if (ImGui.SmallButton("Remove")) { num = index; } ImGui.PopID(); ImGui.PopID(); } ContextMenu.CreateMenu(list, elementType); if (ImGui.SmallButton("Add")) { if (elementType.IsAbstract) { ContextMenu.GetTypes(elementType); ImGui.OpenPopup("WidgetContextMenu"); } else if (elementType == typeof(string)) { list.Add(string.Empty); } else { object value = Activator.CreateInstance(elementType); list.Add(value); } } ImGui.TreePop(); } if (num >= 0) { list.RemoveAt(num); num = -1; } } private static void RemoveAt(Array array, Action set, int index) { int length = array.Length; Type elementType = array.GetType().GetElementType(); Array array2 = Array.CreateInstance(elementType, length - 1); if (index > 0) { Array.Copy(array, 0, array2, 0, index); } if (index < length - 1) { Array.Copy(array, index + 1, array2, index, length - index - 1); } set(array2); } private static void AddElement(Array array, Action set) { int length = array.Length; Type elementType = array.GetType().GetElementType(); Array array2 = Array.CreateInstance(elementType, length + 1); Array.Copy(array, array2, length); set(array2); } public static FieldData[] GetSpecialFieldData(Type t) { FieldData[] fieldDataFromType = GetFieldDataFromType(t); if (t == typeof(PropSpawner) || t == typeof(PropSpawner_Sphere)) { FieldData fieldData = fieldDataFromType.Where((FieldData d) => d.name == "currentSpawns").FirstOrDefault(); if (fieldData != null) { fieldData.widgetMode = WidgetMode.Disabled; } FieldData[] array = fieldDataFromType; foreach (FieldData fieldData2 in array) { if (spawnerHideFieldData.Contains(fieldData2.name)) { fieldData2.widgetMode = WidgetMode.Hidden; } } } return fieldDataFromType; } public static FieldData[] GetFieldDataFromType(Type t) { FieldInfo[] fields = t.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldData[] array = new FieldData[fields.Length]; for (int i = 0; i < fields.Length; i++) { FieldInfo fieldInfo = fields[i]; RangeAttribute customAttribute = ((MemberInfo)fieldInfo).GetCustomAttribute(); array[i] = new FieldData { name = fieldInfo.Name, fieldInfo = fieldInfo, rangeAttribute = customAttribute, widgetMode = WidgetMode.Default, layout = ((fieldInfo.FieldType.IsArray || (fieldInfo.FieldType.IsGenericType && fieldInfo.FieldType.GetGenericTypeDefinition() == typeof(List<>)) || (fieldInfo.FieldType.IsClass && !typeof(Object).IsAssignableFrom(fieldInfo.FieldType))) ? FieldLayout.Full : FieldLayout.Inline) }; } return array; } public static FieldData GetFieldData(FieldInfo fieldInfo) { RangeAttribute customAttribute = ((MemberInfo)fieldInfo).GetCustomAttribute(); FieldData fieldData = new FieldData(); fieldData.name = fieldInfo.Name; fieldData.fieldInfo = fieldInfo; fieldData.rangeAttribute = customAttribute; fieldData.widgetMode = WidgetMode.Default; fieldData.layout = ((fieldInfo.FieldType.IsArray || (fieldInfo.FieldType.IsGenericType && fieldInfo.FieldType.GetGenericTypeDefinition() == typeof(List<>)) || (fieldInfo.FieldType.IsClass && !typeof(Object).IsAssignableFrom(fieldInfo.FieldType))) ? FieldLayout.Full : FieldLayout.Inline); return fieldData; } private static FieldInfo[] GetTypeFields(Type t) { return t.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } } } namespace TerrainCustomiser.UI.Windows { public class AirportWindow : ImGuiWindowBase { private int selectedSaveIndex = 0; private bool useRandomSeed = false; private int seedValue = 0; private bool bakeLightMap = false; public override string WindowName => "TC Menu"; public override ImGuiWindowFlags WindowFlags => (ImGuiWindowFlags)64; public override void OnCreate() { base.OnCreate(); bakeLightMap = PlayerInfoManager.LobbyCanBake && ConfigManager.EnableLightMapBaking.Value && ConfigManager.BakeLightMap.Value; useRandomSeed = ConfigManager.UseRandomSeed.Value; seedValue = ConfigManager.SeedToUse.Value; } protected override void DrawContent() { if (SessionState.Is(SessionState.State.InAirport) || SessionState.Is(SessionState.State.SelectingSave)) { DrawOptionSelectionMenu(); } else if (SessionState.Is(SessionState.State.ConfiguringCustomMap) || SessionState.Is(SessionState.State.WaitingToStartCustomMap)) { DrawPlayConfigMenu(); } } private void DrawOptionSelectionMenu() { if (ImGui.Button("Play")) { SaveSelectionModal.Open(OnSaveSelected); SessionState.Set(SessionState.State.SelectingSave); } SaveSelectionModal.Draw(); ImGui.SameLine(); ImGuiHelpers.DrawButton("Editor", OnEditorButtonClicked, PhotonNetwork.OfflineMode); } private void DrawPlayConfigMenu() { WidgetFactory.FieldWidgetData[] fieldWidgets = new WidgetFactory.FieldWidgetData[3] { new WidgetFactory.FieldWidgetData(typeof(bool), () => useRandomSeed, delegate(object v) { SetUseRandomSeedValue((bool)v); }, "Random Seed"), new WidgetFactory.FieldWidgetData(typeof(int), () => seedValue, delegate { SetSeedValue(seedValue); }, "Seed", null, isHidden: false, useRandomSeed), new WidgetFactory.FieldWidgetData(typeof(bool), () => bakeLightMap && PlayerInfoManager.LobbyCanBake, delegate(object v) { SetBakeLightMapValue((bool)v); }, "Bake LightMap", null, isHidden: false, !PlayerInfoManager.LobbyCanBake) }; ImGuiHelpers.DrawPropertiesTable("PlayConfigTable", fieldWidgets); if (ImGui.BeginListBox("##players")) { Player[] array = ((CachedPlayerList)(ref PlayerHandler.Instance._playerList)).Get(); foreach (Player val in array) { ImGui.TextUnformatted(val.NickName); if (PlayerInfoManager.PlayersInfo.TryGetValue(val, out PlayerInfo value)) { ImGui.SameLine(); ImGui.TextUnformatted(value.canBake ? "CanBake" : "CantBake"); if (SessionState.Is(SessionState.State.LoadingCustomMap)) { ImGui.SameLine(); ImGui.TextUnformatted(value.hasMapData ? "Ready" : "Not Ready"); } } } ImGui.EndListBox(); } ImGuiHelpers.DrawButton("Play", OnPlayClicked, SessionState.Is(SessionState.State.ConfiguringCustomMap)); ImGui.SameLine(); if (ImGui.Button("Cancel")) { OnCancelLoadClicked(); } } private void SetUseRandomSeedValue(bool newValue) { useRandomSeed = newValue; ConfigManager.UseRandomSeed.Value = newValue; } private void SetSeedValue(int newValue) { seedValue = newValue; ConfigManager.SeedToUse.Value = newValue; } private void SetBakeLightMapValue(bool newValue) { bakeLightMap = newValue; ConfigManager.BakeLightMap.Value = newValue; } private void OnSaveSelected(int saveIndex) { selectedSaveIndex = saveIndex; SessionState.Set(SessionState.State.ConfiguringCustomMap); } private void OnEditorButtonClicked() { SessionState.Set(SessionState.State.LoadingEditor); Plugin.Instance.LoadWilIsland(); } private void OnPlayClicked() { SessionState.Set(SessionState.State.WaitingToStartCustomMap); byte[] save = MapSerializer.GetSave(selectedSaveIndex); if (useRandomSeed) { seedValue = Random.Range(0, 999999999); } MapSerializer.MapSyncData mapDataRoomProperty = new MapSerializer.MapSyncData { bakeLightMap = bakeLightMap, seed = seedValue, mapSaveData = save }; NetworkUtils.SetMapDataRoomProperty(mapDataRoomProperty); } private void OnCancelLoadClicked() { NetworkManager.SetRoomProperty("mapData", null); SessionState.Set(SessionState.State.InAirport); } } public class EditorWindow : ImGuiWindowBase { public HierarchyView hierarchy = new HierarchyView(); private int selectedSegmentNodeInstanceId; private MapData.BiomeSegment hierarchyTargetSegment; public override string WindowName => "Editor"; public override ImGuiWindowFlags WindowFlags => (ImGuiWindowFlags)64; public override void OnCreate() { base.OnCreate(); IsOpen = true; Singleton.Instance.SetCurrentSegment(MapData.biomeSections[0].activeBiome.segments[0]); SetupHierarchy(); } private void SetupHierarchy() { HierarchyView hierarchyView = hierarchy; hierarchyView.OnSelectionChanged = (Action)Delegate.Combine(hierarchyView.OnSelectionChanged, (Action)delegate(Transform t) { WindowsManager.Get().SetTarget(t); }); hierarchy.ShouldDrawNode = (Transform t) => (Object)(object)((Component)t).GetComponent() != (Object)null || (Object)(object)((Component)t).GetComponent() != (Object)null || (((Component)t).GetComponents().Length == 1 && (Object)(object)((Component)t.parent).GetComponent() != (Object)null); HierarchyView.ContextNode contextNode = hierarchy.AddContextMenu("Create Spawner", (Transform t) => (Object)(object)t == (Object)null || (Object)(object)((Component)t).GetComponent() == (Object)null); foreach (Type item in Singleton.Instance.levelGenStepTypes) { contextNode.AddContextItem(item.Name, delegate(Transform t) { //IL_0021: 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) Singleton.Instance.CreateObjectWithComponent(item.Name, t, item, ((Component)Camera.main).transform.position, ((Component)Camera.main).transform.rotation); }, null); } hierarchy.AddContextItem("Create Grouper", delegate(Transform t) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) Singleton.Instance.CreateObjectWithComponent("PropGrouper", t, typeof(PropGrouper), ((Component)Camera.main).transform.position, ((Component)Camera.main).transform.rotation); }, (Transform t) => (Object)(object)t == (Object)null || (Object)(object)((Component)t).GetComponent() == (Object)null); hierarchy.AddContextItem("Duplicate", delegate(Transform t) { Singleton.Instance.DuplicateObject(t); }, (Transform t) => (Object)(object)t != (Object)null); hierarchy.AddContextItem("Rename", delegate(Transform t) { RenameModal.RequestOpen(t); }, (Transform t) => (Object)(object)t != (Object)null); hierarchy.AddContextItem("Delete", delegate(Transform t) { Singleton.Instance.DestroyObject(((Component)t).gameObject); }, (Transform t) => (Object)(object)t != (Object)null); } protected override void DrawContent() { DrawControlsList(); DrawBiomeTable(); ImGui.Separator(); DrawHierarchy(); } private void DrawControlsList() { ImGuiHelpers.DrawSmallButton("Generate", Singleton.Instance.GenerateCurrentSegment); ImGui.SameLine(); ImGuiHelpers.DrawSmallButton("Save", SaveModal.Open); ImGui.SameLine(); ImGuiHelpers.DrawSmallButton("Load", LoadModal.Open); ImGui.SameLine(); ImGuiHelpers.DrawSmallButton("Cam", WindowsManager.Get().ToggleOpen); ImGui.SameLine(); ImGuiHelpers.DrawSmallButton("Gizmo", EditorGizmos.ToggleGizmos); SaveModal.Draw(); LoadModal.Draw(); } private void SetSelectedSegment(MapData.BiomeSegment biomeSegment) { selectedSegmentNodeInstanceId = ((Object)biomeSegment.transform).GetInstanceID(); hierarchyTargetSegment = biomeSegment; Singleton.Instance.SetCurrentSegment(biomeSegment); } private void DrawBiomeTable() { if (!ImGui.BeginTable("Table_Biomes", 3)) { return; } ImGui.TableSetupColumn("Name", (ImGuiTableColumnFlags)16, 100f); ImGui.TableSetupColumn("Type", (ImGuiTableColumnFlags)16, 60f); ImGui.TableSetupColumn("Buttons", (ImGuiTableColumnFlags)16, 50f); foreach (MapData.BiomeSection biomeSection in MapData.biomeSections) { DrawBiomeNode(biomeSection); } ImGui.EndTable(); } private void DrawBiomeNode(MapData.BiomeSection biomeSection) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) ImGui.TableNextRow(); ImGui.TableNextColumn(); int instanceID = ((Object)biomeSection.activeBiome.transform).GetInstanceID(); ImGui.PushID(instanceID); ImGui.SetNextItemAllowOverlap(); ImGuiTreeNodeFlags val = (ImGuiTreeNodeFlags)16674; ImGui.PushStyleColor((ImGuiCol)24, Color.op_Implicit(Color.black)); ImGui.PushStyleColor((ImGuiCol)25, Color.op_Implicit(Color.black)); bool flag = ImGui.TreeNodeEx(biomeSection.activeBiome.name, val); ImGui.PopStyleColor(2); ImGui.TableNextColumn(); ImGui.TextUnformatted(biomeSection.name); ImGui.TableNextColumn(); if (ImGui.SmallButton("Swap")) { SwapBiomeModal.Open(biomeSection); } SwapBiomeModal.Draw(); if (flag) { foreach (MapData.BiomeSegment segment in biomeSection.activeBiome.segments) { DrawSegmentNode(segment); } ImGui.TreePop(); } ImGui.PopID(); } private void DrawSegmentNode(MapData.BiomeSegment biomeSegment) { //IL_003d: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) MapData.BiomeSegment biomeSegment2 = biomeSegment; ImGui.TableNextRow(); ImGui.TableNextColumn(); int instanceID = ((Object)biomeSegment2.transform).GetInstanceID(); ImGui.PushID(instanceID); ImGui.SetNextItemAllowOverlap(); ImGuiTreeNodeFlags val = (ImGuiTreeNodeFlags)17160; if (instanceID == selectedSegmentNodeInstanceId) { val = (ImGuiTreeNodeFlags)(val | 1); } bool flag = ImGui.TreeNodeEx(biomeSegment2.name, val); if (ImGui.IsItemClicked()) { SetSelectedSegment(biomeSegment2); } ImGui.TableNextColumn(); MapData.SegmentVariant activeVariant = biomeSegment2.activeVariant; ImGui.TextUnformatted((activeVariant != null) ? biomeSegment2.activeVariant.name : "None"); ImGui.TableNextColumn(); MapData.SegmentVariant customVariant = biomeSegment2.customVariant; ImGuiHelpers.DrawSmallButton("C", delegate { CreateVariantModal.Open(biomeSegment2); }, customVariant == null); if (customVariant != null) { ImGui.SameLine(); if (ImGui.SmallButton("D")) { DeleteSegmentModal.Open(customVariant); } } CreateVariantModal.Draw(); DeleteSegmentModal.Draw(); ImGui.PopID(); } private void DrawHierarchy() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown if (!ImGui.BeginChild("Hierarchy", new Vector2(ImGui.GetContentRegionAvail().x, 220f))) { return; } if (hierarchyTargetSegment == null || hierarchyTargetSegment.customVariant == null) { ImGui.TextUnformatted("No custom variant."); ImGui.EndChild(); return; } foreach (Transform item in hierarchyTargetSegment.customVariant.transform) { Transform t = item; hierarchy.DrawNode(t); } if (RenameModal.OpenRequested) { RenameModal.Open(); } RenameModal.Draw(); if (ImGui.BeginPopupContextWindow("HierarchyWindowContextMenuPopup", (ImGuiPopupFlags)385)) { hierarchy.DrawContextNodes(null); ImGui.EndPopup(); } ImGui.EndChild(); } } public class FreeCamWindow : ImGuiWindowBase { public override string WindowName => "GodCam Settings"; public override ImGuiWindowFlags WindowFlags => (ImGuiWindowFlags)2; public override Vector2 InitialWindowSize => new Vector2(275f, 150f); private GodCam godCam => Singleton.Instance?.godcam; protected override void DrawContent() { if (godCam != null) { WidgetFactory.FieldWidgetData[] fieldWidgets = new WidgetFactory.FieldWidgetData[4] { new WidgetFactory.FieldWidgetData(typeof(float), () => godCam.lookSens, delegate(object v) { godCam.lookSens = (float)v; }, "Look Sensitivity"), new WidgetFactory.FieldWidgetData(typeof(float), () => godCam.lookDrag, delegate(object v) { godCam.lookDrag = (float)v; }, "Look Drag"), new WidgetFactory.FieldWidgetData(typeof(float), () => godCam.force, delegate(object v) { godCam.force = (float)v; }, "Force"), new WidgetFactory.FieldWidgetData(typeof(float), () => godCam.drag, delegate(object v) { godCam.drag = (float)v; }, "Drag") }; ImGuiHelpers.DrawPropertiesTable("godCamTable", fieldWidgets); } } } public abstract class ImGuiWindowBase { public bool IsOpen = false; public virtual string WindowName => "Window"; public virtual Vector2 InitialWindowSize => Vector2.zero; public virtual ImGuiWindowFlags WindowFlags => (ImGuiWindowFlags)0; public virtual void OnCreate() { } public virtual void OnDestroy() { } public void ToggleOpen() { IsOpen = !IsOpen; } public void Close() { IsOpen = false; } public void Open() { IsOpen = true; } public void DrawWindow() { //IL_0011: 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) if (IsOpen) { ImGui.SetNextWindowSize(InitialWindowSize, (ImGuiCond)2); if (ImGui.Begin(WindowName, WindowFlags)) { DrawContent(); ImGui.End(); } } } protected abstract void DrawContent(); } public class InspectorWindow : ImGuiWindowBase { private GameObject targetGO; public static List allowedTypes = new List { typeof(PropGrouper), typeof(Transform), typeof(RockMaterialSwapper), typeof(SpecialDayZone) }; public override string WindowName => "Inspector"; public override Vector2 InitialWindowSize => new Vector2(300f, 600f); public override void OnCreate() { base.OnCreate(); IsOpen = true; foreach (Type levelGenStepType in Singleton.Instance.levelGenStepTypes) { allowedTypes.Add(levelGenStepType); } } public void SetTarget(Transform targetTransform) { if ((Object)(object)targetTransform == (Object)null) { targetGO = null; return; } targetGO = ((Component)targetTransform).gameObject; Component[] components = targetGO.GetComponents(); Component[] array = components; foreach (Component val in array) { Type type = ((object)val).GetType(); if (allowedTypes.Contains(type) && !WidgetFactory.TypeFieldDataDictionary.ContainsKey(type)) { WidgetFactory.FieldData[] specialFieldData = WidgetFactory.GetSpecialFieldData(type); WidgetFactory.TypeFieldDataDictionary.Add(type, specialFieldData); } } } private void DrawTransformComponent(Transform targetTransform) { Transform targetTransform2 = targetTransform; if (ImGui.TreeNodeEx("Transform", (ImGuiTreeNodeFlags)34)) { WidgetFactory.FieldWidgetData[] fieldWidgets = new WidgetFactory.FieldWidgetData[2] { new WidgetFactory.FieldWidgetData(typeof(Vector3), () => targetTransform2.position, delegate(object v) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) targetTransform2.position = (Vector3)v; }, "Position"), new WidgetFactory.FieldWidgetData(typeof(Vector3), () => targetTransform2.eulerAngles, delegate(object v) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) targetTransform2.eulerAngles = (Vector3)v; }, "Rotation") }; ImGuiHelpers.DrawPropertiesTable("transformTable", fieldWidgets); ImGui.TreePop(); } } protected override void DrawContent() { if ((Object)(object)targetGO == (Object)null) { return; } Component[] components = targetGO.GetComponents(); Component[] array = components; foreach (Component component in array) { Type type = ((object)component).GetType(); if (!allowedTypes.Contains(type)) { continue; } if (type == typeof(Transform)) { DrawTransformComponent(targetGO.transform); continue; } WidgetFactory.FieldData[] array2 = WidgetFactory.TypeFieldDataDictionary[type]; if (array2 == null || !ImGui.TreeNodeEx(type.Name, (ImGuiTreeNodeFlags)34)) { continue; } IEnumerable enumerable = array2.Where((WidgetFactory.FieldData f) => f.layout == WidgetFactory.FieldLayout.Inline); IEnumerable enumerable2 = array2.Where((WidgetFactory.FieldData f) => f.layout == WidgetFactory.FieldLayout.Full); List list = new List(); foreach (WidgetFactory.FieldData tableField in enumerable) { WidgetFactory.FieldWidgetData item = new WidgetFactory.FieldWidgetData(tableField.fieldInfo.FieldType, () => tableField.fieldInfo.GetValue(component), delegate(object v) { tableField.fieldInfo.SetValue(component, v); }, tableField.name, tableField.rangeAttribute, tableField.widgetMode == WidgetFactory.WidgetMode.Hidden, tableField.widgetMode == WidgetFactory.WidgetMode.Disabled); list.Add(item); } ImGuiHelpers.DrawPropertiesTable(((Object)component).name, list.ToArray()); foreach (WidgetFactory.FieldData data in enumerable2) { WidgetFactory.FieldWidgetData fieldWidget = new WidgetFactory.FieldWidgetData(data.fieldInfo.FieldType, () => data.fieldInfo.GetValue(component), delegate(object v) { data.fieldInfo.SetValue(component, v); }, data.name, data.rangeAttribute, data.widgetMode == WidgetFactory.WidgetMode.Hidden, data.widgetMode == WidgetFactory.WidgetMode.Disabled); ImGuiHelpers.DrawFullLayoutField(fieldWidget); } ImGui.TreePop(); } } } public class ResourceWindow : ImGuiWindowBase { private static int _selectedIndex = -1; private static readonly List _items = new List(); private static string filterBuffer = string.Empty; private static Func _get; private static Action _set; public override string WindowName => "Resources"; public override ImGuiWindowFlags WindowFlags => (ImGuiWindowFlags)64; public static void Show(Func get, Action set) where T : Object { Func get2 = get; Action set2 = set; _get = () => (Object)(object)get2(); _set = delegate(Object o) { set2((T)(object)o); }; RebuildList(); T val = get2(); _selectedIndex = (((Object)(object)val != (Object)null) ? _items.IndexOf((Object)(object)val) : (-1)); } private static void RebuildList() where T : Object { //IL_006a: 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) _items.Clear(); T[] array = Resources.FindObjectsOfTypeAll(); if (typeof(T) == typeof(GameObject)) { foreach (GameObject item in array.Cast()) { if (!((Object)(object)item == (Object)null) && (Object)(object)item.transform.parent == (Object)null) { Scene scene = item.scene; if (!((Scene)(ref scene)).IsValid()) { _items.Add((Object)(object)item); } } } } else if (typeof(T) == typeof(Transform)) { GetTransformsFromRoot(GameObject.Find("Custom").transform); } else { T[] array2 = array; foreach (T val in array2) { if (!((Object)(object)val == (Object)null)) { _items.Add((Object)(object)val); } } } _items.Sort((Object a, Object b) => string.Compare(a.name, b.name, StringComparison.OrdinalIgnoreCase)); } private static void GetTransformsFromRoot(Transform t) { _items.Add((Object)(object)t); for (int i = 0; i < t.childCount; i++) { GetTransformsFromRoot(t.GetChild(i)); } } protected override void DrawContent() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) WidgetFactory.FieldWidgetData[] fieldWidgets = new WidgetFactory.FieldWidgetData[1] { new WidgetFactory.FieldWidgetData(typeof(string), () => filterBuffer, delegate(object v) { filterBuffer = (string)v; }, "Filter") }; ImGuiHelpers.DrawPropertiesTable("ResourceWindowTable", fieldWidgets); if (ImGui.BeginListBox("##resource_list", new Vector2(300f, 200f))) { for (int i = 0; i < _items.Count; i++) { if (!string.IsNullOrEmpty(filterBuffer) && !_items[i].name.Contains(filterBuffer, StringComparison.OrdinalIgnoreCase)) { continue; } Object val = _items[i]; bool flag = _selectedIndex == i; string text = ((val != (Object)null) ? val.name : ""); if (ImGui.Selectable(text, flag, (ImGuiSelectableFlags)4)) { _selectedIndex = i; if (ImGui.IsMouseDoubleClicked((ImGuiMouseButton)0)) { if (val != (Object)null && _set != null) { _set(val); } _get = null; _set = null; IsOpen = false; } } if (flag) { ImGui.SetItemDefaultFocus(); } } ImGui.EndListBox(); } if (ImGui.Button("Cancel")) { IsOpen = false; } } } } namespace TerrainCustomiser.UI.Modals { public static class ConfirmationModal { private static Action ConfirmAction; private static string Message = string.Empty; public static void Open(string message, Action confirmAction) { Message = message; ConfirmAction = confirmAction; ImGui.OpenPopup("Confirm Action"); } public static void Draw() { if (ImGui.BeginPopupModal("Confirm Action", (ImGuiWindowFlags)64)) { ImGui.TextUnformatted(Message); if (ImGui.Button("Confirm")) { ConfirmAction(); ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button("Cancel")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } } } public static class CreateVariantModal { private static Vector2 ModalSize = new Vector2(275f, 100f); private static MapData.BiomeSegment TargetSegment; private static string[] VariantOptionNames; private static int SelectedVariantIndex = 0; private static bool HasOptions = false; public static void Open(MapData.BiomeSegment biomeSegment) { TargetSegment = biomeSegment; if (biomeSegment.variantSelectionType == MapData.VariantSelectionType.BiomeVariant) { VariantOptionNames = biomeSegment.variants.Select((MapData.SegmentVariant x) => x.name).ToArray(); SelectedVariantIndex = biomeSegment.variants.FindIndex((MapData.SegmentVariant x) => x.isActive); } else { VariantOptionNames = biomeSegment.variantObjects.Select((MapData.SegmentVariant x) => x.name).ToArray(); SelectedVariantIndex = biomeSegment.variantObjects.FindIndex((MapData.SegmentVariant x) => x.isActive); } HasOptions = VariantOptionNames.Length != 0; ImGui.OpenPopup("Create Variant"); } public static void Draw() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (ImGui.BeginPopupModal("Create Variant", (ImGuiWindowFlags)2)) { ImGui.SetWindowSize(ModalSize); WidgetFactory.FieldWidgetData[] fieldWidgets = new WidgetFactory.FieldWidgetData[1] { new WidgetFactory.ComboWidgetData("Variant Template", () => SelectedVariantIndex, delegate(int v) { SelectedVariantIndex = v; }, () => VariantOptionNames) }; if (!HasOptions) { ImGui.BeginDisabled(); } ImGuiHelpers.DrawPropertiesTable("CreateVariantModalTable", fieldWidgets); if (!HasOptions) { ImGui.EndDisabled(); } if (ImGui.Button("Create")) { MapManager.CreateVariant(TargetSegment, HasOptions ? SelectedVariantIndex : (-1)); ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button("Cancel")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } } } public static class DeleteSegmentModal { private static MapData.SegmentVariant TargetSegment; public static void Open(MapData.SegmentVariant targetSegment) { TargetSegment = targetSegment; ImGui.OpenPopup("Delete Segment"); } public static void Draw() { if (!ImGui.BeginPopupModal("Delete Segment", (ImGuiWindowFlags)64)) { return; } ImGui.TextUnformatted("Delete your custom segment?"); if (ImGui.Button("Yes")) { if (TargetSegment != null) { MapManager.DeleteSegmentVariant(TargetSegment); } ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button("No")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } } public static class LoadModal { private static Vector2 ModalSize = new Vector2(275f, 200f); private static int selectedSaveIndex = 0; public static void Open() { MapSerializer.RefreshSaveList(); ImGui.OpenPopup("Load Save"); } public static void Draw() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (!ImGui.BeginPopupModal("Load Save", (ImGuiWindowFlags)2)) { return; } ImGui.SetWindowSize(ModalSize); ImGui.SetNextItemWidth(-1f); if (ImGui.BeginListBox("##saves")) { for (int i = 0; i < MapSerializer.SaveFiles.Count; i++) { bool flag = i == selectedSaveIndex; if (ImGui.Selectable(MapSerializer.SaveFiles[i], flag)) { selectedSaveIndex = i; } } ImGui.EndListBox(); } if (ImGui.Button("Load")) { MapSerializer.MapSaveData save = MapSerializer.LoadSave(selectedSaveIndex); MapLoader.ApplySave(save); ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button("Cancel")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } } public static class RenameModal { private static Vector2 ModalSize = new Vector2(275f, 150f); private static string RenameBuffer = string.Empty; private static Transform Selected; public static bool OpenRequested = false; private static Transform TransformRequested; public static void RequestOpen(Transform t) { OpenRequested = true; TransformRequested = t; } public static void Open() { if ((Object)(object)TransformRequested == (Object)null) { OpenRequested = false; return; } Selected = TransformRequested; RenameBuffer = ((Object)Selected).name; OpenRequested = false; ImGui.OpenPopup("Rename Object"); } public static void Draw() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (ImGui.BeginPopupModal("Rename Object", (ImGuiWindowFlags)2)) { ImGui.SetWindowSize(ModalSize); WidgetFactory.FieldWidgetData[] fieldWidgets = new WidgetFactory.FieldWidgetData[1] { new WidgetFactory.FieldWidgetData(typeof(string), () => RenameBuffer, delegate(object v) { RenameBuffer = (string)v; }, "Name") }; ImGuiHelpers.DrawPropertiesTable("RenameModalTable", fieldWidgets); if (ImGui.Button("Apply")) { ((Object)Selected).name = RenameBuffer; ImGui.CloseCurrentPopup(); RenameBuffer = string.Empty; } ImGui.SameLine(); if (ImGui.Button("Cancel")) { ImGui.CloseCurrentPopup(); RenameBuffer = string.Empty; } ImGui.EndPopup(); } } } public static class SaveModal { private static string saveName = "New Save"; public static void Open() { ImGui.OpenPopup("Save Map"); } public static void Draw() { if (ImGui.BeginPopupModal("Save Map")) { WidgetFactory.FieldWidgetData[] fieldWidgets = new WidgetFactory.FieldWidgetData[1] { new WidgetFactory.FieldWidgetData(typeof(string), () => saveName, delegate(object v) { saveName = (string)v; }, "Save Name") }; ImGuiHelpers.DrawPropertiesTable("saveModalTable", fieldWidgets); if (ImGui.Button("Save")) { MapSaver.SaveTerrain(saveName); ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button("Cancel")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } } } public static class SaveSelectionModal { private static Vector2 ModalSize = new Vector2(275f, 225f); private static int SelectedSaveIndex = 0; private static Action OnSelectAction; private static string FilterInput = string.Empty; public static void Open(Action onSelectAction) { MapSerializer.RefreshSaveList(); OnSelectAction = onSelectAction; ImGui.OpenPopup("Save Selection"); } public static void Draw() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (!ImGui.BeginPopupModal("Save Selection", (ImGuiWindowFlags)2)) { return; } ImGui.SetWindowSize(ModalSize); WidgetFactory.FieldWidgetData[] fieldWidgets = new WidgetFactory.FieldWidgetData[1] { new WidgetFactory.FieldWidgetData(typeof(string), () => FilterInput, delegate(object v) { FilterInput = (string)v; }, "Filter") }; ImGuiHelpers.DrawPropertiesTable("SaveSelectionModalTable", fieldWidgets); ImGui.SetNextItemWidth(-1f); if (ImGui.BeginListBox("##saves")) { for (int i = 0; i < MapSerializer.SaveFiles.Count; i++) { if (string.IsNullOrEmpty(FilterInput) || MapSerializer.SaveFiles[i].Contains(FilterInput, StringComparison.OrdinalIgnoreCase)) { bool flag = i == SelectedSaveIndex; if (ImGui.Selectable(MapSerializer.SaveFiles[i], flag)) { SelectedSaveIndex = i; } } } ImGui.EndListBox(); } if (ImGui.Button("Select")) { OnSelectAction(SelectedSaveIndex); ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button("Cancel")) { ImGui.CloseCurrentPopup(); SessionState.Set(SessionState.State.InAirport); } ImGui.EndPopup(); } } public static class SwapBiomeModal { private static Vector2 ModalSize = new Vector2(275f, 100f); private static MapData.BiomeSection TargetSection; private static string[] BiomeOptionNames; private static int SelectedBiomeIndex = 0; private static bool OverrideConfirmed = false; public static void Open(MapData.BiomeSection biomeSection) { TargetSection = biomeSection; BiomeOptionNames = biomeSection.biomes.Select((MapData.BiomeOption x) => x.name).ToArray(); SelectedBiomeIndex = biomeSection.biomes.FindIndex((MapData.BiomeOption x) => x.isActive); ImGui.OpenPopup("SwapBiomeModal"); } public static void Draw() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (!ImGui.BeginPopupModal("SwapBiomeModal", (ImGuiWindowFlags)2)) { return; } ImGui.SetWindowSize(ModalSize); WidgetFactory.FieldWidgetData[] fieldWidgets = new WidgetFactory.FieldWidgetData[1] { new WidgetFactory.ComboWidgetData("Biome", () => SelectedBiomeIndex, delegate(int v) { SelectedBiomeIndex = v; }, () => BiomeOptionNames) }; ImGuiHelpers.DrawPropertiesTable("SwapBiomeModalTable", fieldWidgets); if (ImGui.Button("Apply")) { if (TargetSection.activeBiome.segmentHasCustomVariant) { ConfirmationModal.Open("Custom variants for this Biome will be deleted. Continue?", delegate { OverrideConfirmed = true; }); } else { Singleton.Instance.ChangeBiome(TargetSection, TargetSection.biomes[SelectedBiomeIndex]); ImGui.CloseCurrentPopup(); } } ConfirmationModal.Draw(); if (OverrideConfirmed) { Singleton.Instance.ChangeBiome(TargetSection, TargetSection.biomes[SelectedBiomeIndex]); OverrideConfirmed = false; ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button("Cancel")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } } } namespace TerrainCustomiser.TerrainGeneration { public static class AreaVoxeliser { [BurstCompile] private struct BuildOverlapCommandsJob : IJobParallelFor { [WriteOnly] public NativeArray commands; public int3 gridRes; public float spacing; public float3 offset; public float3 halfExtents; public QueryParameters query; public void Execute(int index) { //IL_0077: 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_007e: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) int num = index % gridRes.x; int num2 = index / gridRes.x % gridRes.y; int num3 = index / (gridRes.x * gridRes.y); float3 val = default(float3); ((float3)(ref val))..ctor(((float)num + 0.5f) * spacing, ((float)num2 + 0.5f) * spacing, ((float)num3 + 0.5f) * spacing); val -= float3.op_Implicit(gridRes) * spacing * 0.5f; val += offset; commands[index] = new OverlapBoxCommand(float3.op_Implicit(val), float3.op_Implicit(halfExtents), quaternion.op_Implicit(quaternion.identity), query); } } [BurstCompile] private struct ProcessOverlapResultsJob : IJobParallelFor { [ReadOnly] public NativeArray results; [WriteOnly] public NativeArray occupancy; public void Execute(int index) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) ref NativeArray reference = ref occupancy; ColliderHit val = results[index]; reference[index] = ((((ColliderHit)(ref val)).instanceID != 0) ? 1u : 0u); } } private static NativeArray commands; private static NativeArray results; public static NativeArray occupancyNative; public static NativeArray BuildOccupancyGrid(LayerMask occluderMask) { //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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_0097: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e1: 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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: 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_0140: Unknown result type (might be due to invalid IL or missing references) LightVolume val = LightVolume.Instance(); Vector3Int gridRes = val.gridRes; float raySpacing = val.raySpacing; int num = ((Vector3Int)(ref gridRes)).x * ((Vector3Int)(ref gridRes)).y * ((Vector3Int)(ref gridRes)).z; CreateArrays(num); float3 offset = float3.op_Implicit(val.gridOffset); float3 halfExtents = default(float3); ((float3)(ref halfExtents))..ctor(raySpacing * 0.5f); BuildOverlapCommandsJob buildOverlapCommandsJob = default(BuildOverlapCommandsJob); buildOverlapCommandsJob.commands = commands; buildOverlapCommandsJob.gridRes = new int3(((Vector3Int)(ref gridRes)).x, ((Vector3Int)(ref gridRes)).y, ((Vector3Int)(ref gridRes)).z); buildOverlapCommandsJob.spacing = raySpacing; buildOverlapCommandsJob.offset = offset; buildOverlapCommandsJob.halfExtents = halfExtents; buildOverlapCommandsJob.query = new QueryParameters { layerMask = LayerMask.op_Implicit(occluderMask), hitTriggers = (QueryTriggerInteraction)1 }; BuildOverlapCommandsJob buildOverlapCommandsJob2 = buildOverlapCommandsJob; JobHandle val2 = IJobParallelForExtensions.Schedule(buildOverlapCommandsJob2, num, 128, default(JobHandle)); JobHandle val3 = OverlapBoxCommand.ScheduleBatch(commands, results, 128, 1, val2); ProcessOverlapResultsJob processOverlapResultsJob = default(ProcessOverlapResultsJob); processOverlapResultsJob.results = results; processOverlapResultsJob.occupancy = occupancyNative; ProcessOverlapResultsJob processOverlapResultsJob2 = processOverlapResultsJob; JobHandle val4 = IJobParallelForExtensions.Schedule(processOverlapResultsJob2, num, 128, val3); ((JobHandle)(ref val4)).Complete(); return occupancyNative; } private static void CreateArrays(int voxelCount) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_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_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) DisposeArrays(); commands = new NativeArray(voxelCount, (Allocator)4, (NativeArrayOptions)1); results = new NativeArray(voxelCount, (Allocator)4, (NativeArrayOptions)1); occupancyNative = new NativeArray(voxelCount, (Allocator)4, (NativeArrayOptions)1); } public static void DisposeArrays() { if (commands.IsCreated) { commands.Dispose(); } if (results.IsCreated) { results.Dispose(); } if (occupancyNative.IsCreated) { occupancyNative.Dispose(); } } } public static class GenerationPatches { [HarmonyPatch] public static class RemoveDebugLogsPatch { [CompilerGenerated] private sealed class d__0 : IEnumerable, IEnumerable, IEnumerator, IEnumerator, IDisposable { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; private IEnumerable instructions; public IEnumerable <>3__instructions; private MethodInfo 5__1; private MethodInfo 5__2; private IEnumerator <>s__3; private CodeInstruction 5__4; CodeInstruction IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 1u) { try { } finally { <>m__Finally1(); } } 5__1 = null; 5__2 = null; <>s__3 = null; 5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = AccessTools.Method(typeof(Debug), "Log", new Type[1] { typeof(object) }, (Type[])null); 5__2 = AccessTools.Method(typeof(Debug), "LogError", new Type[1] { typeof(object) }, (Type[])null); <>s__3 = instructions.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; break; case 2: <>1__state = -3; 5__4 = null; break; } if (<>s__3.MoveNext()) { 5__4 = <>s__3.Current; if (CodeInstructionExtensions.Calls(5__4, 5__1) || CodeInstructionExtensions.Calls(5__4, 5__2)) { <>2__current = new CodeInstruction(OpCodes.Pop, (object)null); <>1__state = 1; return true; } <>2__current = 5__4; <>1__state = 2; return true; } <>m__Finally1(); <>s__3 = null; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>s__3 != null) { <>s__3.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { d__0 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__0(0); } d__.instructions = <>3__instructions; return d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } [IteratorStateMachine(typeof(d__0))] [HarmonyTranspiler] [HarmonyPatch(typeof(JungleVine), "Awake")] [HarmonyPatch(typeof(JungleVine), "PickTreePlatforms")] [HarmonyPatch(typeof(SpawnConnectingBridge), "CheckCondition")] private static IEnumerable Transpiler(IEnumerable instructions) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(-2) { <>3__instructions = instructions }; } } [HarmonyPatch(typeof(Looker), "ToggleLookers")] internal static class ToggleLookersPatch { public static bool Prefix(Looker __instance) { Looker[] componentsInChildren = ((Component)((Component)__instance).transform.parent).GetComponentsInChildren(); int num = Random.Range(0, componentsInChildren.Length); if (Random.value < 0.95f) { num = -1; } Looker[] array = componentsInChildren; Looker[] array2 = array; foreach (Looker val in array2) { if ((Object)(object)val.view == (Object)null) { val.view = ((Component)val).GetComponent(); } if (((Component)val).transform.GetSiblingIndex() != num) { val.view.RPC("RPCA_DisableLooker", (RpcTarget)3, Array.Empty()); } } return false; } } [HarmonyPatch(typeof(PropGrouper), "RunAll")] public static class PropGrouperRunAllPatch { public static Dictionary> deferredSteps = new Dictionary>(); private static void AddToStepList(DeferredStepTiming key, IDeferredStep stepToAdd) { //IL_0006: 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_0019: Unknown result type (might be due to invalid IL or missing references) if (!deferredSteps.ContainsKey(key)) { deferredSteps.Add(key, new List()); } deferredSteps[key].Add(stepToAdd); } private static void ExecuteAndClearDeferredStepsFor(DeferredStepTiming key) { //IL_0006: 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_0055: Unknown result type (might be due to invalid IL or missing references) if (!deferredSteps.ContainsKey(key)) { return; } foreach (IDeferredStep item in deferredSteps[key]) { item.DeferredGo(); } deferredSteps[key].Clear(); } public static bool Prefix(PropGrouper __instance, bool updateLightmap = true) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Invalid comparison between Unknown and I4 //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Invalid comparison between Unknown and I4 //IL_00bf: Unknown result type (might be due to invalid IL or missing references) if (!SessionState.CanGenerate) { return true; } deferredSteps.Clear(); __instance.ClearAll(); LevelGenStep[] componentsInChildren = ((Component)__instance).GetComponentsInChildren(); List list = new List(); List list2 = new List(); for (int i = 0; i < componentsInChildren.Length; i++) { PropGrouperTiming timing = ((Component)componentsInChildren[i]).GetComponentInParent().timing; PropGrouperTiming val = timing; if ((int)val != 0) { if ((int)val == 1) { list2.Add(componentsInChildren[i]); } } else { list.Add(componentsInChildren[i]); } } foreach (LevelGenStep item in list) { item.Execute(); if ((int)item.DeferredTiming > 0) { AddToStepList(item.DeferredTiming, item.ConstructDeferred((IMayHaveDeferredStep)(object)item)); } } ((PhotonPeer)PhotonNetwork.NetworkingClient.LoadBalancingPeer).SendOutgoingCommands(); if (ConfigManager.EnableLightMapBaking.Value && updateLightmap) { LightMapBaker.RunBake(); } ((PhotonPeer)PhotonNetwork.NetworkingClient.LoadBalancingPeer).SendOutgoingCommands(); ExecuteAndClearDeferredStepsFor((DeferredStepTiming)2); foreach (LevelGenStep item2 in list2) { item2.Execute(); } return false; } } [HarmonyPatch(typeof(PropSpawner_Sphere), "SpawnNew")] public static class PropSpawnerSphereAddPatch { private static Ray[] rays = (Ray[])(object)new Ray[0]; private static bool Prefix(PropSpawner_Sphere __instance, bool executeDeferredImmediately) { //IL_00af: 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) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_0103: 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_010c: 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_0134: 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_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: 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_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_017c: 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_0187: 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_019c: Expected O, but got Unknown //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Invalid comparison between Unknown and I4 if (!SessionState.CanGenerate) { return true; } if (__instance.spawnChance < Random.value) { return false; } if (!CanBatch(((Object)((Component)__instance).gameObject).name, __instance.rayCastSpawn, __instance.syncTransforms)) { return true; } int num = __instance.nrOfSpawns; if (__instance.randomSpawns) { num = Random.Range(__instance.minSpawnCount, __instance.nrOfSpawns); } int num2 = 50000; int num3 = 0; int num4 = 256; if (rays.Length < num4) { rays = (Ray[])(object)new Ray[num4]; } LayerMask mask = HelperFunctions.GetMask(__instance.layerType); QueryParameters @default = QueryParameters.Default; @default.layerMask = ((LayerMask)(ref mask)).value; @default.hitTriggers = (QueryTriggerInteraction)1; NativeArray results = default(NativeArray); results..ctor(num4, (Allocator)3, (NativeArrayOptions)1); NativeArray commands = default(NativeArray); commands..ctor(num4, (Allocator)3, (NativeArrayOptions)1); while (num3 < num && num2 > 0) { rays = PropSpawnerHelpers.BuildRays_Sphere(__instance, rays, num4); ExecuteJob(commands, results, rays, @default, num4, __instance.rayLength); num2 -= num4; int num5 = 0; for (int i = 0; i < num4; i++) { if (num3 >= num) { break; } RaycastHit hit = results[i]; if (!Object.op_Implicit((Object)(object)((RaycastHit)(ref hit)).transform)) { continue; } SpawnData val = new SpawnData { pos = ((RaycastHit)(ref hit)).point, normal = ((RaycastHit)(ref hit)).normal, rayDir = ((Ray)(ref rays[i])).direction, hit = hit, spawnerTransform = ((Component)__instance).transform }; bool flag = true; for (int j = 0; j < __instance.constraints.Count; j++) { if (!__instance.constraints[j].CheckConstraint(val)) { flag = false; break; } } if (flag) { GameObject val2 = Spawn(__instance, val); if ((Object)(object)val2 != (Object)null) { __instance.spawnedProps.Add(val2); num3++; num5++; } } } if (num <= 10 && num5 == 0) { break; } } commands.Dispose(); results.Dispose(); foreach (PostSpawnBehavior postSpawnBehavior in __instance.postSpawnBehaviors) { if (!postSpawnBehavior.mute) { if (executeDeferredImmediately || (int)postSpawnBehavior.DeferredTiming != 2) { postSpawnBehavior.RunBehavior((IEnumerable)__instance.spawnedProps); } else { __instance._deferredSteps.Add(postSpawnBehavior.ConstructDeferred((IMayHaveDeferredStep)(object)__instance)); } } } return false; } private static GameObject Spawn(PropSpawner_Sphere spawner, SpawnData spawnData) { //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_0021: Unknown result type (might be due to invalid IL or missing references) GameObject val = HelperFunctions.SpawnPrefab(spawner.props[Random.Range(0, spawner.props.Length)], spawnData.pos, HelperFunctions.GetRandomRotationWithUp(Vector3.up), ((Component)spawner).transform); if ((Object)(object)val == (Object)null) { return null; } for (int i = 0; i < spawner.modifiers.Count; i++) { spawner.modifiers[i].ModifyObject(val, spawnData); } for (int j = 0; j < spawner.postConstraints.Count; j++) { if (!spawner.postConstraints[j].CheckConstraint(val, spawnData)) { Object.DestroyImmediate((Object)(object)val); return null; } } return val; } } [HarmonyPatch(typeof(PropSpawner), "SpawnNew")] public static class PropSpawnerSpawnNewPatch { private static Ray[] rays = (Ray[])(object)new Ray[0]; private static bool Prefix(PropSpawner __instance, bool executeDeferredImmediately) { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_00f2: 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_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0134: 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_013d: 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) if (!SessionState.CanGenerate) { return true; } if (__instance.chanceToUseSpawner < 0.999f && Random.value > __instance.chanceToUseSpawner) { return false; } if (!CanBatch(((Object)((Component)__instance).gameObject).name, __instance.raycastPosition, __instance.syncTransforms)) { return true; } int num = __instance.nrOfSpawns; if (__instance.randomSpawns) { num = Random.Range(__instance.minSpawnCount, __instance.nrOfSpawns); } int num2 = 25000; int i = 0; int num3 = 256; LayerMask mask = HelperFunctions.GetMask(__instance.layerType); if (rays.Length < num3) { rays = (Ray[])(object)new Ray[num3]; } Vector3 val = ((Component)__instance).transform.forward + __instance.rayDirectionOffset; Vector3 normalized = ((Vector3)(ref val)).normalized; QueryParameters @default = QueryParameters.Default; @default.layerMask = ((LayerMask)(ref mask)).value; @default.hitTriggers = (QueryTriggerInteraction)1; NativeArray results = default(NativeArray); results..ctor(num3, (Allocator)3, (NativeArrayOptions)1); NativeArray commands = default(NativeArray); commands..ctor(num3, (Allocator)3, (NativeArrayOptions)1); int num4; for (; i < num; i += num4) { if (num2 <= 0) { break; } rays = PropSpawnerHelpers.BuildRays(__instance, rays, num3, normalized); ExecuteJob(commands, results, rays, @default, num3, __instance.rayLength); num2 -= num3; num4 = ProcessResults(results, rays, __instance, i, num); } commands.Dispose(); results.Dispose(); Physics.SyncTransforms(); __instance.currentSpawns = ((Component)__instance).transform.childCount; __instance.SpawnDecor(); HandlePostSpawnBehaviors(__instance, executeDeferredImmediately); return false; } private static void HandlePostSpawnBehaviors(PropSpawner __instance, bool executeDeferredImmediately) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Invalid comparison between Unknown and I4 foreach (PostSpawnBehavior postSpawnBehavior in __instance.postSpawnBehaviors) { if (!postSpawnBehavior.mute) { if (executeDeferredImmediately || (int)postSpawnBehavior.DeferredTiming != 2) { postSpawnBehavior.RunBehavior(__instance.SpawnedProps); } else { __instance._deferredSteps.Add(postSpawnBehavior.ConstructDeferred((IMayHaveDeferredStep)(object)__instance)); } } } } } [HarmonyPatch(typeof(PropSpawner), "Execute")] public static class PropSpawnerExecutePatch { private static bool Prefix(PropSpawner __instance) { if (__instance.props == null || __instance.props.Length == 0) { Debug.LogError((object)("[TC] PropSpawner " + ((Object)__instance).name + " has null or empty props array.")); return false; } return true; } } [HarmonyPatch(typeof(PropSpawner_Sphere), "Execute")] public static class PropSpawner_SphereExecutePatch { private static bool Prefix(PropSpawner_Sphere __instance) { if (__instance.props == null || __instance.props.Length == 0) { Debug.LogError((object)("[TC] PropSpawner_Sphere " + ((Object)__instance).name + " has null or empty props array.")); return false; } return true; } } [HarmonyPatch(typeof(PropSpawner_Line), "Execute")] public static class PropSpawner_LineExecutePatch { private static bool Prefix(PropSpawner_Line __instance) { if (__instance.props == null || __instance.props.Length == 0) { Debug.LogError((object)("[TC] PropSpawner_Line " + ((Object)__instance).name + " has null or empty props array.")); return false; } return true; } } [HarmonyPatch(typeof(PropSpawner), "Spawn")] private class PropSpawnerSpawnPatch { private static bool Prefix(PropSpawner __instance, SpawnData spawnData, ref GameObject __result) { if (!SessionState.CanGenerate) { return true; } if (__instance.props == null) { return true; } return PropSpawnerHelpers.TrySpawn(spawnData, ref __result, __instance.props, __instance.modifiers, __instance.postConstraints, ((Component)__instance).transform, ((Component)__instance).gameObject); } } [HarmonyPatch(typeof(PropSpawner_Sphere), "Spawn")] private class PropSpawner_SphereSpawnPatch { private static bool Prefix(PropSpawner_Sphere __instance, SpawnData spawnData, ref GameObject __result) { if (!SessionState.CanGenerate) { return true; } if (__instance.props == null) { return true; } return PropSpawnerHelpers.TrySpawn(spawnData, ref __result, __instance.props, __instance.modifiers, __instance.postConstraints, ((Component)__instance).transform, ((Component)__instance).gameObject); } } [HarmonyPatch(typeof(PropSpawner_Line), "Spawn")] private class PropSpawner_LineSpawnPatch { private static bool Prefix(PropSpawner_Line __instance, SpawnData spawnData, ref GameObject __result) { if (!SessionState.CanGenerate) { return true; } if (__instance.props == null) { return true; } return PropSpawnerHelpers.TrySpawn(spawnData, ref __result, __instance.props, __instance.modifiers, __instance.postConstraints, ((Component)__instance).transform, ((Component)__instance).gameObject); } } [HarmonyPatch(typeof(PropSpawner_Sphere), "Clear")] private class PropSpawner_SphereClearPatch { private static void Postfix(PropSpawner_Sphere __instance) { if (SessionState.CanGenerate) { __instance.spawnedProps.Clear(); } } } [HarmonyPatch(typeof(MapHandler), "InitializeMap")] private static class MapHandlerInitializeMapPatch { private static bool Prefix() { if (SessionState.Is(SessionState.State.WaitingForMapData)) { return false; } if (SessionState.Is(SessionState.State.LoadingEditor) || SessionState.Is(SessionState.State.WaitingToStartCustomMap)) { MapData.BuildMapData(); TerrainCustomiser.Map.ResourceManager.GetAllResources(); } if (!SessionState.Is(SessionState.State.WaitingToStartCustomMap)) { return true; } LoadCustomMap(); return true; } private static void LoadCustomMap() { SessionState.Set(SessionState.State.LoadingCustomMap); AddGroupersToSegments(); MapSerializer.MapSaveData save = MapSerializer.LoadFromBytes(PlayerInfoManager.currentMapSyncData.mapSaveData); Random.InitState(PlayerInfoManager.currentMapSyncData.seed); MapLoader.ApplySave(save); PropGrouper component = ((Component)Singleton.Instance).GetComponent(); bool flag = PlayerInfoManager.LocalPlayerInfo.canBake && PlayerInfoManager.currentMapSyncData.bakeLightMap; component.RunAll(flag); HandleRemainingPhotonViews(); FakeItemManager.Instance.RefreshList(); } private static void AddGroupersToSegments() { List list = Singleton.Instance.segments.ToList(); list.AddRange(Singleton.Instance.variantSegments); foreach (MapSegment item in list) { if ((Object)(object)item.segmentParent.GetComponent() == (Object)null) { item.segmentParent.gameObject.AddComponent(); } } } private static void HandleRemainingPhotonViews() { List allUnassignedViews = GetAllUnassignedViews(); foreach (PhotonView item in allUnassignedViews) { ViewSyncManager.AddPendingView(item); } ViewSyncManager.HandlePendingViews(); } public static List GetAllUnassignedViews() { PhotonView[] componentsInChildren = ((Component)Singleton.Instance).gameObject.GetComponentsInChildren(true); List list = new List(); for (int i = 0; i < componentsInChildren.Length; i++) { if (componentsInChildren[i].ViewID == 0) { list.Add(componentsInChildren[i]); } } return list; } } public static bool CanBatch(string spawnerName, bool raycastPosition, bool syncTransforms) { if (!raycastPosition) { return false; } if (!syncTransforms || PropSpawnerHelpers.SafeToBatchPropNames.Contains(spawnerName)) { return true; } return true; } public static bool PassedConstraints(PropSpawner spawner, SpawnData sd) { for (int i = 0; i < spawner.constraints.Count; i++) { if (!spawner.constraints[i].CheckConstraint(sd)) { return false; } } return true; } public static void ExecuteJob(NativeArray commands, NativeArray results, Ray[] rays, QueryParameters queryParams, int batchCount, float rayLength) { //IL_0010: 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_0021: 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_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_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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < batchCount; i++) { commands[i] = new RaycastCommand(((Ray)(ref rays[i])).origin, ((Ray)(ref rays[i])).direction, queryParams, rayLength); } JobHandle val = RaycastCommand.ScheduleBatch(commands, results, 4, default(JobHandle)); ((JobHandle)(ref val)).Complete(); } public static int ProcessResults(NativeArray results, Ray[] rays, PropSpawner spawner, int successes, int nrOfSpawns) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_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) int num = 0; int num2 = 0; for (int i = 0; i < results.Length; i++) { if (successes >= nrOfSpawns) { break; } RaycastHit hit = results[i]; if ((Object)(object)((RaycastHit)(ref hit)).collider == (Object)null) { continue; } num++; SpawnData val = PropSpawnerHelpers.BuildSpawnData(spawner, rays[i], hit, hasHit: true, successes); if (PassedConstraints(spawner, val)) { GameObject val2 = spawner.Spawn(val); if ((Object)(object)val2 != (Object)null) { successes++; num2++; spawner.AllSpawnData[val2] = val; } } } return num2; } } public static class LightMapBaker { public static ComputeShader computeShader; public static int rayCount = 128; public static int maxSteps = 64; public static void RunBake() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_005f: 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) LightVolume val = LightVolume.Instance(); val.lightMap = null; Shader.SetGlobalTexture("_LightMap", (Texture)null); Stopwatch stopwatch = Stopwatch.StartNew(); NativeArray occupancy = AreaVoxeliser.BuildOccupancyGrid(val.occluderMask); stopwatch.Stop(); Debug.Log((object)("[TerrainCustomiser] Occupancy took: " + stopwatch.ElapsedMilliseconds)); stopwatch = Stopwatch.StartNew(); RenderTexture val2 = DispatchAndCreateRenderTexture(computeShader, occupancy, val.gridRes, rayCount, maxSteps, val.skyColor); AreaVoxeliser.DisposeArrays(); RenderTexture val3 = val.RunBlur(val2); ((Object)val3).name = "LightVolumeRenderTexture"; val.SetShaderVars(); val.SaveTex(val3, (Action)null); stopwatch.Stop(); Debug.Log((object)("[TerrainCustomiser] Visibility took: " + stopwatch.ElapsedMilliseconds)); } private static RenderTexture DispatchAndCreateRenderTexture(ComputeShader cs, NativeArray occupancy, Vector3Int gridRes, int rayCount, int maxSteps, Color skyColor) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_002e: 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_004a: Expected O, but got Unknown //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) //IL_006f: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown //IL_00e6: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) int num = cs.FindKernel("SkyVisibilityDDA"); int num2 = ((Vector3Int)(ref gridRes)).x * ((Vector3Int)(ref gridRes)).y * ((Vector3Int)(ref gridRes)).z; ComputeBuffer val = new ComputeBuffer(num2, 4); val.SetData(occupancy); List list = BuildLights(); ComputeBuffer val2 = new ComputeBuffer(list.Count, 52); val2.SetData(list); RenderTexture val3 = new RenderTexture(((Vector3Int)(ref gridRes)).x, ((Vector3Int)(ref gridRes)).y, 0) { enableRandomWrite = true, format = (RenderTextureFormat)2, dimension = (TextureDimension)3, volumeDepth = ((Vector3Int)(ref gridRes)).z, wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; val3.Create(); LightVolume val4 = LightVolume.Instance(); cs.SetInts("_GridRes", new int[3] { ((Vector3Int)(ref gridRes)).x, ((Vector3Int)(ref gridRes)).y, ((Vector3Int)(ref gridRes)).z }); cs.SetVector("_GridOffset", Vector4.op_Implicit(val4.gridOffset)); cs.SetFloat("_RaySpacing", val4.raySpacing); cs.SetBuffer(num, "_Occupancy", val); cs.SetTexture(num, "_LightMap", (Texture)(object)val3); cs.SetInt("_RayCount", rayCount); cs.SetInt("_MaxSteps", maxSteps); cs.SetVector("_SkyColor", Color.op_Implicit(skyColor)); cs.SetBuffer(num, "_LightBuffer", val2); cs.SetInt("_LightBufferLength", list.Count); int num3 = (((Vector3Int)(ref gridRes)).x + 3) / 4; int num4 = (((Vector3Int)(ref gridRes)).y + 3) / 4; int num5 = (((Vector3Int)(ref gridRes)).z + 3) / 4; cs.Dispatch(num, num3, num4, num5); val.Release(); val2.Release(); return val3; } public static List BuildLights() { //IL_0072: 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_007d: 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_0160: 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_0086: Invalid comparison between Unknown and I4 //IL_00b5: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) LightVolume val = LightVolume.Instance(); List list = new List(); GameObject val2 = (((Object)(object)val.sceneParent == (Object)null) ? ((Component)val).gameObject : val.sceneParent); BakedVolumeLight[] componentsInChildren = val2.GetComponentsInChildren(); BakedVolumeLight[] array = componentsInChildren; Vector3 val4 = default(Vector3); foreach (BakedVolumeLight val3 in array) { ((Vector3)(ref val4))..ctor(val3.color.r, val3.color.g, val3.color.b); LightModes mode = val3.mode; if (1 == 0) { } float num; if ((int)mode != 0) { if ((int)mode != 1) { throw new Exception(); } num = val3.coneSize * (MathF.PI / 180f); } else { num = 0f; } if (1 == 0) { } float coneSize = num; list.Add(new GpuLight { Position = ((Component)val3).transform.position, ConeSize = coneSize, Direction = ((Component)val3).transform.forward, Radius = val3.GetRadius(), Color = val4 * val3.intensity, Falloff = val3.falloff, ConeFalloff = val3.coneFalloff }); } if (list.Count == 0) { list.Add(default(GpuLight)); } return list; } } public static class PropGrouperHelpers { public static Dictionary> deferredSteps = new Dictionary>(); private static void AddToStepList(DeferredStepTiming key, IDeferredStep stepToAdd) { //IL_0006: 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_0019: Unknown result type (might be due to invalid IL or missing references) if (!deferredSteps.ContainsKey(key)) { deferredSteps.Add(key, new List()); } deferredSteps[key].Add(stepToAdd); } private static void ExecuteAndClearDeferredStepsFor(DeferredStepTiming key) { //IL_0006: 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_0055: Unknown result type (might be due to invalid IL or missing references) if (!deferredSteps.ContainsKey(key)) { return; } foreach (IDeferredStep item in deferredSteps[key]) { item.DeferredGo(); } deferredSteps[key].Clear(); } public static void RunRootPropGrouper(PropGrouper rootGrouper) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0047: Invalid comparison between Unknown and I4 //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Invalid comparison between Unknown and I4 //IL_00a4: Unknown result type (might be due to invalid IL or missing references) deferredSteps.Clear(); rootGrouper.ClearAll(); LevelGenStep[] componentsInChildren = ((Component)rootGrouper).GetComponentsInChildren(); List list = new List(); List list2 = new List(); for (int i = 0; i < componentsInChildren.Length; i++) { PropGrouperTiming timing = ((Component)componentsInChildren[i]).GetComponentInParent().timing; PropGrouperTiming val = timing; if ((int)val != 0) { if ((int)val == 1) { list2.Add(componentsInChildren[i]); } } else { list.Add(componentsInChildren[i]); } } foreach (LevelGenStep item in list) { item.Execute(); if ((int)item.DeferredTiming > 0) { AddToStepList(item.DeferredTiming, item.ConstructDeferred((IMayHaveDeferredStep)(object)item)); } } ((PhotonPeer)PhotonNetwork.NetworkingClient.LoadBalancingPeer).SendOutgoingCommands(); if (ConfigManager.EnableLightMapBaking.Value) { LightMapBaker.RunBake(); } ((PhotonPeer)PhotonNetwork.NetworkingClient.LoadBalancingPeer).SendOutgoingCommands(); ExecuteAndClearDeferredStepsFor((DeferredStepTiming)2); foreach (LevelGenStep item2 in list2) { item2.Execute(); } } } public static class PropSpawnerHelpers { public static readonly HashSet SafeToBatchPropNames = new HashSet { "LuggageSpawner", "Ivy", "Geysers", "Weed", "ExploShrooms", "PoisonShrooms", "Vines", "BeachGrass", "Driftwood", "Behive", "ShittyPiton", "Monsteras", "FlashPlant", "Shrub", "Pine", "Bushes", "Trees", "DeadTree", "Ice_DeadTree", "Palms", "Luggage", "Cacti", "Dynamite", "Ferns", "Zombie Spawner", "Exploding Shrooms", "Glow Mushrooms", "Spiders", "Bounce Shrooms", "Shroom Spawners", "Root Spawner", "Evil Shroom" }; public static bool TrySpawn(SpawnData spawnData, ref GameObject __result, GameObject[] props, List modifiers, List postConstraints, Transform parent, GameObject fallback) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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) if (props == null) { __result = null; return false; } GameObject val = props[Random.Range(0, props.Length)]; PhotonView val2 = default(PhotonView); if ((Object)(object)val != (Object)null && val.TryGetComponent(ref val2)) { Quaternion randomRotationWithUp = GetRandomRotationWithUp(Vector3.up); GameObject val3 = Object.Instantiate(val, spawnData.pos, randomRotationWithUp, parent); if ((Object)(object)val3 == (Object)null) { Debug.LogError((object)("Failed to instantiate prop " + ((Object)val).name)); __result = null; return false; } RemoveSpineIfLuggage(val3); ApplyModifiers(val3, spawnData, modifiers); if (!CheckAndHandlePostConstraints(val3, spawnData, postConstraints)) { __result = null; return false; } if ((Object)(object)val3 == (Object)null) { __result = null; return false; } HandleIfBridge(val3); PhotonView component = val3.GetComponent(); if (PhotonNetwork.OfflineMode) { PhotonNetwork.AllocateViewID(component); } else { ViewSyncManager.AddPendingView(component); } __result = val3; return false; } return true; } public static Quaternion GetRandomRotationWithUp(Vector3 normal) { //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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) Vector3 onUnitSphere = Random.onUnitSphere; onUnitSphere.y = 0f; onUnitSphere = Vector3.Cross(normal, Vector3.Cross(normal, onUnitSphere)); return Quaternion.LookRotation(onUnitSphere, normal); } public static bool CheckAndHandlePostConstraints(GameObject go, SpawnData spawnData, List postConstraints) { foreach (PropSpawnerConstraintPost postConstraint in postConstraints) { if (postConstraint.mute || postConstraint.CheckConstraint(go, spawnData)) { continue; } Object.DestroyImmediate((Object)(object)go); return false; } return true; } public static void ApplyModifiers(GameObject go, SpawnData spawnData, List modifiers) { foreach (PropSpawnerMod modifier in modifiers) { if (!modifier.mute) { modifier.ModifyObject(go, spawnData); } } } public static void RemoveSpineIfLuggage(GameObject go) { Luggage val = default(Luggage); if (go.TryGetComponent(ref val)) { SpineCheck component = go.GetComponent(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } } } public static void HandleIfBridge(GameObject go) { BreakableBridge @object = default(BreakableBridge); if (go.TryGetComponent(ref @object)) { CollisionModifier[] componentsInChildren = go.GetComponentsInChildren(); CollisionModifier[] array = componentsInChildren; foreach (CollisionModifier val in array) { val.applyEffects = false; val.onCollide = (Action)Delegate.Combine(val.onCollide, new Action(@object.OnBridgeCollision)); } } } public static bool CheckIfBridge(GameObject go) { BreakableBridge val = default(BreakableBridge); if (go.TryGetComponent(ref val)) { return true; } return false; } public static Ray[] BuildRays_Sphere(PropSpawner_Sphere spawner, Ray[] outRays, int count) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_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_001b: 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_0021: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)spawner).transform.position; for (int i = 0; i < count; i++) { Vector3 onUnitSphere = Random.onUnitSphere; outRays[i] = new Ray(position, onUnitSphere); } return outRays; } public static Ray[] BuildRays(PropSpawner spawner, Ray[] outRays, int count, Vector3 rayDir) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < count; i++) { outRays[i] = GetSpawnRay(spawner.area, ((Component)spawner).transform, rayDir); } return outRays; } public static Ray GetSpawnRay(Vector2 area, Transform t, Vector3 rayDir) { //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_0023: 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_003c: 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_0052: 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_0069: 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_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_008a: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(Random.value, Random.value); Vector3 val2 = t.position + t.right * Mathf.Lerp((0f - area.x) * 0.5f, area.x * 0.5f, val.x) + t.up * Mathf.Lerp((0f - area.y) * 0.5f, area.y * 0.5f, val.y); return new Ray(val2, rayDir); } public static SpawnData BuildSpawnData(PropSpawner spawner, Ray ray, RaycastHit hit, bool hasHit, int count) { //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_0024: 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_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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown Vector2 placement = default(Vector2); ((Vector2)(ref placement))..ctor(Random.value, Random.value); return new SpawnData { pos = ((RaycastHit)(ref hit)).point, normal = ((RaycastHit)(ref hit)).normal, rayDir = ((Component)spawner).transform.forward, hit = hit, spawnerTransform = ((Component)spawner).transform, placement = placement, spawnCount = count }; } } } namespace TerrainCustomiser.Session { internal static class SessionActions { internal static void OnQuitToMainMenu() { if (SessionState.Is(SessionState.State.InEditor) && (Object)(object)Singleton.Instance != (Object)null) { Singleton.Instance.EndSession(); } } internal static void OnLobbyEnter() { string lobbyData = NetworkManager.GetLobbyData("TC_inCustomMap"); if (!string.IsNullOrEmpty(lobbyData) && lobbyData == "true") { SessionState.Set(SessionState.State.WaitingForMapData); } } internal static void OnAirportEnter() { SessionState.Set(SessionState.State.InAirport); if (PhotonNetwork.IsMasterClient) { NetworkManager.SetRoomProperty("mapData", null); NetworkManager.SetLobbyData("TC_inCustomMap", "false"); } } internal static void OnStartRun() { if (SessionState.Is(SessionState.State.LoadingEditor)) { EditorManager.Setup(); } else if (SessionState.Is(SessionState.State.LoadingCustomMap)) { SessionState.Set(SessionState.State.InCustomMap); if (PhotonNetwork.IsMasterClient) { NetworkManager.SetLobbyData("TC_inCustomMap", "true"); } } } } internal static class SessionState { public enum State { InMainMenu, InAirport, SelectingSave, ConfiguringCustomMap, WaitingToStartCustomMap, LoadingCustomMap, WaitingForMapData, LoadingEditor, InCustomMap, InEditor } public static State Current { get; private set; } public static bool CanGenerate => Current == State.LoadingCustomMap || Current == State.LoadingEditor || Current == State.InEditor; public static void Set(State state) { Current = state; } public static bool Is(State state) { return Current == state; } } } namespace TerrainCustomiser.Patches { internal class AirportPatches { [HarmonyPatch(typeof(GameUtils), "OnEnable")] private class GameUtilsOnEnablePatch { private static void Postfix(GameUtils __instance) { if (__instance.m_inAirport) { SessionActions.OnAirportEnter(); } } } [HarmonyPatch(typeof(BoardingPass), "Initialize")] private class BoardingPassInitializePatch { private static void Postfix(BoardingPass __instance) { WindowsManager.Register(); } } [HarmonyPatch(typeof(BoardingPass), "OnOpen")] private class BoardingPassOnOpenPatch { private static void Postfix() { if (PhotonNetwork.IsMasterClient) { WindowsManager.Get().Open(); } } } [HarmonyPatch(typeof(BoardingPass), "OnClose")] private class BoardingPassOnClosePatch { private static void Postfix() { if (PhotonNetwork.IsMasterClient) { WindowsManager.Get().Close(); } } } [HarmonyPatch(typeof(AirportCheckInKiosk), "BeginIslandLoadRPC")] private class BeginIslandLoadRPCPatch { private static void Postfix() { WindowsManager.Unregister(); } } } internal class NetworkPatches { [HarmonyPatch(typeof(GameHandler), "Awake")] private class GameHandlerAwakePatch { private static void Postfix(GameHandler __instance) { NetworkManager.Setup(); } } [HarmonyPatch(typeof(GameUtils), "OnPlayerLeftRoom")] private class OnPlayerLeftRoomPatch { private static void Postfix(Player newPlayer) { PlayerInfoManager.RemovePlayerInfo(newPlayer); } } } internal class SessionPatches { [HarmonyPatch(typeof(MainMenu), "Start")] private class MainMenuStartPatch { private static void Postfix(MainMenu __instance) { SessionState.Set(SessionState.State.InMainMenu); } } [HarmonyPatch(typeof(RunManager), "StartRun")] public class RunManagerStartRunPatch { private static void Postfix() { SessionActions.OnStartRun(); } } [HarmonyPatch(typeof(PauseMenuMainPage), "Quit")] private class PauseMenQuitPatch { private static void Postfix() { SessionActions.OnQuitToMainMenu(); } } [HarmonyPatch(typeof(SteamLobbyHandler), "OnLobbyEnter")] private static class OnLobbyEnterPatch { private static void Postfix(SteamLobbyHandler __instance, LobbyEnter_t param) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if (param.m_EChatRoomEnterResponse == 1) { SessionActions.OnLobbyEnter(); } } } } } namespace TerrainCustomiser.Map { public static class MapData { public enum VariantSelectionType { BiomeVariant, VariantObject } public class BiomeSection { public string name; public Transform transform; public List biomes = new List(); public BiomeOption activeBiome => biomes.Find((BiomeOption x) => x.isActive); } public class BiomeOption { public string name; public Transform transform; public BiomeType biomeType; public BiomeSection section; public List segments = new List(); public bool isActive => ((Component)transform).gameObject.activeSelf; public bool segmentHasCustomVariant => segments.Find((BiomeSegment x) => x.customVariant != null) != null; } public class BiomeSegment { public string name; public Transform transform; public BiomeOption biome; public VariantSelectionType variantSelectionType = VariantSelectionType.VariantObject; public List variants = new List(); public List variantObjects = new List(); public SegmentVariant initialVariant; public SegmentVariant customVariant => variants.Find((SegmentVariant x) => x.isCustom); public SegmentVariant activeVariant => variants.Find((SegmentVariant x) => x.isActive); } public class SegmentVariant { public string name; public Transform transform; public BiomeSegment segment; public bool isCustom = false; public bool isInitial = false; public bool isActive => ((Component)transform).gameObject.activeSelf; } public static List biomeSections = new List(); public static void BuildMapData() { biomeSections.Clear(); MapHandler instance = Singleton.Instance; GetBiomeSections(instance); } private static void GetBiomeSections(MapHandler mapHandler) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown foreach (Transform item in ((Component)mapHandler).transform) { Transform val = item; if ((Object)(object)((Component)val).GetComponent() != (Object)null) { BiomeSection biomeSection = new BiomeSection { name = ((Object)val).name, transform = val }; GetBiomeOptions(biomeSection); biomeSections.Add(biomeSection); } } } private static void GetBiomeOptions(BiomeSection biomeSection) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) Biome val2 = default(Biome); foreach (Transform item in biomeSection.transform) { Transform val = item; if (((Component)val).TryGetComponent(ref val2)) { BiomeOption biomeOption = new BiomeOption { name = ((Object)val).name, transform = val, biomeType = val2.biomeType, section = biomeSection }; GetBiomeSegments(biomeOption); biomeSection.biomes.Add(biomeOption); } } } private static void GetBiomeSegments(BiomeOption biomeOption) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown foreach (Transform item in biomeOption.transform) { Transform val = item; if (((Object)val).name.Contains("Segment")) { BiomeSegment biomeSegment = new BiomeSegment { name = ((Object)val).name, transform = val, biome = biomeOption }; VariationSwapper componentInChildren = ((Component)biomeSegment.transform).GetComponentInChildren(true); biomeSegment.variantSelectionType = ((!((Object)(object)componentInChildren != (Object)null)) ? VariantSelectionType.VariantObject : VariantSelectionType.BiomeVariant); GetSegmentVariants(biomeSegment); biomeOption.segments.Add(biomeSegment); } } } private static void GetSegmentVariants(BiomeSegment biomeSegment) { if (biomeSegment.variantSelectionType == VariantSelectionType.BiomeVariant) { VariationSwapper componentInChildren = ((Component)biomeSegment.transform).GetComponentInChildren(true); Variation[] variations = componentInChildren.Variations; foreach (Variation val in variations) { SegmentVariant segmentVariant = new SegmentVariant { name = ((Object)val.parent).name, transform = val.parent.transform, segment = biomeSegment, isInitial = val.parent.activeSelf }; if (segmentVariant.isInitial) { biomeSegment.initialVariant = segmentVariant; } biomeSegment.variants.Add(segmentVariant); } } else { MapManager.PrepareDefaultVariant(biomeSegment); VariantObject[] componentsInChildren = ((Component)biomeSegment.transform).GetComponentsInChildren(true); VariantObject[] array = componentsInChildren; foreach (VariantObject val2 in array) { SegmentVariant item = new SegmentVariant { name = ((Object)val2).name, transform = ((Component)val2).transform, segment = biomeSegment }; biomeSegment.variantObjects.Add(item); } } } } public static class MapLoader { public static void ApplySave(MapSerializer.MapSaveData save) { //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Expected O, but got Unknown ((Component)Singleton.Instance).GetComponent().ClearAll(); foreach (MapData.BiomeSection biomeSection2 in MapData.biomeSections) { foreach (MapData.BiomeOption biome in biomeSection2.biomes) { if (!biome.segmentHasCustomVariant) { continue; } foreach (MapData.BiomeSegment segment in biome.segments) { if (segment.customVariant != null) { MapManager.DeleteSegmentVariant(segment.customVariant); } } } } foreach (MapSerializer.SegmentSaveData seg in save.Segments) { if (seg.SectionIndex < 0) { continue; } MapData.BiomeSection biomeSection = MapData.biomeSections[seg.SectionIndex]; MapData.BiomeOption biomeOption = biomeSection.biomes.FirstOrDefault((MapData.BiomeOption b) => b.biomeType == seg.BiomeType); if (biomeOption == null) { continue; } if (biomeSection.activeBiome != biomeOption) { MapManager.ChangeBiome(biomeSection, biomeOption); } MapData.BiomeSegment biomeSegment = biomeOption.segments[seg.SegmentIndex]; if (biomeSegment.customVariant != null) { MapManager.DeleteSegmentVariant(biomeSegment.customVariant); } ((Component)biomeSegment.activeVariant.transform).gameObject.SetActive(false); GameObject val = RebuildObjectData(seg.CustomVariant); ((Object)val).name = "Custom"; val.transform.SetParent(biomeSegment.transform, false); MapData.SegmentVariant segmentVariant = new MapData.SegmentVariant { name = "Custom", isCustom = true, transform = val.transform, segment = biomeSegment }; biomeSegment.variants.Add(segmentVariant); ((Component)segmentVariant.transform).gameObject.SetActive(true); if ((Object)(object)val.GetComponent() == (Object)null) { val.AddComponent(); } if ((Object)(object)val.GetComponent() == (Object)null) { val.AddComponent(); } foreach (Transform item in val.transform) { Transform val2 = item; EnableCustomObject(((Component)val2).gameObject); } } MapSerializer.GameObjectReferences.Clear(); MapSerializer.testgos.Clear(); } private static void EnableCustomObject(GameObject go) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown go.SetActive(true); foreach (Transform item in go.transform) { Transform val = item; EnableCustomObject(((Component)val).gameObject); } } public static GameObject RebuildObjectData(MapSerializer.ObjectData data) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) MapSerializer.ObjectData data2 = data; GameObject val = MapSerializer.testgos.Find((GameObject x) => ((Object)x).name == data2.Id); GameObject val2; if ((Object)(object)val != (Object)null) { val2 = val; ((Object)val2).name = data2.Name; } else { val2 = new GameObject(data2.Name); val2.SetActive(false); } MapSerializer.GameObjectReferences[data2.Id] = val2; val2.transform.localPosition = data2.Transform.Position; val2.transform.localEulerAngles = data2.Transform.Rotation; val2.transform.localScale = data2.Transform.Scale; foreach (MapSerializer.ComponentData component in data2.Components) { if (component.Type == typeof(Transform)) { continue; } Component obj = val2.AddComponent(component.Type); foreach (MapSerializer.FieldData field2 in component.Fields) { FieldInfo field = component.Type.GetField(field2.Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!(field == null)) { object value = field2.Value; try { field.SetValue(obj, value); } catch { } } } } foreach (MapSerializer.ObjectData child in data2.Children) { GameObject val3 = RebuildObjectData(child); val3.transform.SetParent(val2.transform, false); } return val2; } } public static class MapManager { public static void ChangeBiome(MapData.BiomeSection biomeSection, MapData.BiomeOption targetBiome) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) if (biomeSection.activeBiome.segmentHasCustomVariant) { foreach (MapData.BiomeSegment segment in biomeSection.activeBiome.segments) { MapData.SegmentVariant customVariant = segment.customVariant; if (customVariant != null) { DeleteSegmentVariant(customVariant); } } } int index = Singleton.Instance.biomes.IndexOf(biomeSection.activeBiome.biomeType); Singleton.Instance.biomes[index] = targetBiome.biomeType; ((Component)biomeSection.activeBiome.transform).gameObject.SetActive(false); ((Component)targetBiome.transform).gameObject.SetActive(true); } public static void DeleteSegmentVariant(MapData.SegmentVariant targetVariant) { MapData.BiomeSegment segment = targetVariant.segment; segment.variants.Remove(targetVariant); Object.Destroy((Object)(object)((Component)targetVariant.transform).gameObject); targetVariant = null; ((Component)segment.initialVariant.transform).gameObject.SetActive(true); } public static void AssignNewPhotonIds(PhotonView[] views) { foreach (PhotonView val in views) { val.ViewID = 0; PhotonNetwork.AllocateViewID(val); } } public static void CreateVariant(MapData.BiomeSegment biomeSegment, int variantIndex) { ((Component)biomeSegment.transform).GetComponentInParent().ClearAll(); ((Component)biomeSegment.activeVariant.transform).gameObject.SetActive(false); if (biomeSegment.variantSelectionType == MapData.VariantSelectionType.BiomeVariant) { MapData.SegmentVariant segmentVariant = biomeSegment.variants[variantIndex]; Transform val = Object.Instantiate(segmentVariant.transform); ((Component)val).transform.SetParent(biomeSegment.transform, false); ((Object)val).name = "Custom"; MapData.SegmentVariant segmentVariant2 = new MapData.SegmentVariant { name = "Custom", isCustom = true, transform = val, segment = biomeSegment }; biomeSegment.variants.Add(segmentVariant2); PhotonView[] componentsInChildren = ((Component)val).GetComponentsInChildren(true); AssignNewPhotonIds(componentsInChildren); ((Component)segmentVariant2.transform).gameObject.SetActive(true); return; } Transform val2 = Object.Instantiate(biomeSegment.initialVariant.transform); ((Component)val2).transform.SetParent(biomeSegment.transform, false); ((Object)val2).name = "Custom"; MapData.SegmentVariant segmentVariant3 = new MapData.SegmentVariant { name = "Custom", isCustom = true, transform = val2, segment = biomeSegment }; biomeSegment.variants.Add(segmentVariant3); VariantObject[] componentsInChildren2 = ((Component)val2).GetComponentsInChildren(true); if (variantIndex != -1) { MapData.SegmentVariant segmentVariant4 = biomeSegment.variantObjects[variantIndex]; for (int i = 0; i < componentsInChildren2.Length; i++) { if (((Object)componentsInChildren2[i]).name != segmentVariant4.name) { Object.Destroy((Object)(object)((Component)componentsInChildren2[i]).gameObject); } else { ((Component)componentsInChildren2[i]).gameObject.SetActive(true); } } } List list = new List(); GetAllInactiveSelfGameObjects(segmentVariant3.transform, list); foreach (GameObject item in list) { Object.Destroy((Object)(object)item); } PhotonView[] componentsInChildren3 = ((Component)val2).GetComponentsInChildren(true); AssignNewPhotonIds(componentsInChildren3); ((Component)segmentVariant3.transform).gameObject.SetActive(true); } private static void GetAllInactiveSelfGameObjects(Transform target, List results) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown foreach (Transform item in target) { Transform val = item; if (!Object.op_Implicit((Object)(object)((Component)val).GetComponent())) { if (!((Component)val).gameObject.activeSelf) { results.Add(((Component)val).gameObject); } else { GetAllInactiveSelfGameObjects(val, results); } } } } public static void PrepareDefaultVariant(MapData.BiomeSegment biomeSegment) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown if (biomeSegment.variantSelectionType != MapData.VariantSelectionType.VariantObject) { return; } GameObject val = new GameObject("Default"); val.transform.SetParent(biomeSegment.transform); List list = new List(); foreach (Transform item in biomeSegment.transform) { Transform val2 = item; if ((Object)(object)((Component)val2).gameObject.GetComponent() != (Object)null) { list.Add(val2); } } foreach (Transform item2 in list) { item2.SetParent(val.transform); } DesertRockSpawner componentInChildren = ((Component)biomeSegment.transform).GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { ((Component)componentInChildren).transform.SetParent(biomeSegment.transform); } Transform val3 = TransformExtensions.FindChildRecursive(biomeSegment.transform, "GroundMesh"); if ((Object)(object)val3 != (Object)null) { val3.SetParent(biomeSegment.transform); } val.gameObject.AddComponent(); val.gameObject.AddComponent(); MapData.SegmentVariant segmentVariant = new MapData.SegmentVariant { name = "Default", isCustom = false, transform = val.transform, segment = biomeSegment, isInitial = true }; biomeSegment.variants.Add(segmentVariant); biomeSegment.initialVariant = segmentVariant; } public static void DisableInactiveSegments() { MapSegment[] variantSegments = Singleton.Instance.variantSegments; foreach (MapSegment val in variantSegments) { val.segmentParent.SetActive(false); if ((Object)(object)val.segmentCampfire != (Object)null) { val.segmentCampfire.SetActive(false); } } } } public static class MapSaver { public static void SaveTerrain(string saveName) { //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Expected O, but got Unknown //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown //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) ((Component)Singleton.Instance).GetComponent().ClearAll(); MapSerializer.MapSaveData mapSaveData = new MapSerializer.MapSaveData { MapName = saveName }; for (int i = 0; i < MapData.biomeSections.Count; i++) { MapData.BiomeOption activeBiome = MapData.biomeSections[i].activeBiome; if (!activeBiome.segmentHasCustomVariant) { continue; } for (int j = 0; j < activeBiome.segments.Count; j++) { if (activeBiome.segments[j].customVariant != null) { MapSerializer.SegmentSaveData item = new MapSerializer.SegmentSaveData { SectionIndex = i, SegmentIndex = j, BiomeType = activeBiome.biomeType, CustomVariant = MapSerializer.BuildObjectData(activeBiome.segments[j].customVariant.transform) }; mapSaveData.Segments.Add(item); } } } Directory.CreateDirectory(MapSerializer.SavePath); string path = Path.Combine(MapSerializer.SavePath, saveName + ".json"); using MemoryStream memoryStream = new MemoryStream(); JsonDataWriter val = new JsonDataWriter((Stream)memoryStream, new SerializationContext(), false); SerializationUtility.SerializeValue(mapSaveData, (IDataWriter)(object)val); File.WriteAllBytes(path, memoryStream.ToArray()); } } public static class ResourceManager { public static List GameObjectResources = new List(); public static List MaterialResources = new List(); public static void GetAllResources() { GetAllGameObjectResources(); GetAllMaterialResources(); } private static void GetAllGameObjectResources() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) GameObjectResources.Clear(); GameObject[] array = Resources.FindObjectsOfTypeAll(); GameObject[] array2 = array; foreach (GameObject val in array2) { if (!((Object)(object)val == (Object)null) && (Object)(object)val.transform.parent == (Object)null) { Scene scene = val.scene; if (!((Scene)(ref scene)).IsValid()) { GameObjectResources.Add(val); } } } } private static void GetAllMaterialResources() { MaterialResources.Clear(); Material[] array = Resources.FindObjectsOfTypeAll(); Material[] array2 = array; foreach (Material val in array2) { if (!((Object)(object)val == (Object)null)) { MaterialResources.Add(val); } } } } } namespace TerrainCustomiser.Map.Serialization { public static class MapSerializer { public class ObjectData { public string Id; public string Name; public TransformData Transform; public List Components = new List(); public List Children = new List(); } public class TransformData { public Vector3 Position; public Vector3 Rotation; public Vector3 Scale; } public class ComponentData { public Type Type; public List Fields = new List(); } public class FieldData { public string Name; public Type Type; public object Value; } public class MapSaveData { public string MapName; public List Segments = new List(); } public class MapSyncData { public int seed; public bool bakeLightMap; public byte[] mapSaveData; } public class SegmentSaveData { public int SectionIndex; public int SegmentIndex; public BiomeType BiomeType; public ObjectData CustomVariant; } internal static readonly string SavePath = Path.Combine(Application.persistentDataPath, "TerrainCustomiser", "Map Saves"); internal static List SaveFiles = new List(); public static Dictionary GameObjectReferences = new Dictionary(); public static List testgos = new List(); public static string GetIdFromGameObject(GameObject go) { GameObject go2 = go; KeyValuePair keyValuePair = GameObjectReferences.FirstOrDefault>((KeyValuePair x) => (Object)(object)x.Value == (Object)(object)go2); if ((Object)(object)keyValuePair.Value == (Object)null) { string text = Guid.NewGuid().ToString("N"); GameObjectReferences.Add(text, go2); return text; } return keyValuePair.Key; } public static string GetPathFromGameObject(GameObject go) { Transform val = go.transform; if ((Object)(object)val == (Object)null) { return null; } StringBuilder stringBuilder = new StringBuilder(((Object)val).name); while ((Object)(object)val.parent != (Object)null) { val = val.parent; stringBuilder.Insert(0, ((Object)val).name + "/"); } return stringBuilder.ToString(); } public static void RefreshSaveList() { if (Directory.Exists(SavePath)) { SaveFiles.Clear(); IEnumerable enumerable = Directory.GetFiles(SavePath, "*.json").Select(Path.GetFileName); if (enumerable != null) { SaveFiles.AddRange(enumerable); } } } public static byte[] GetSave(int selectedSaveIndex) { string path = Path.Combine(SavePath, SaveFiles[selectedSaveIndex]); if (!File.Exists(path)) { return null; } return File.ReadAllBytes(path); } public static MapSaveData LoadSave(int selectedSaveIndex) { byte[] save = GetSave(selectedSaveIndex); return SerializationUtility.DeserializeValue(save, (DataFormat)1, (DeserializationContext)null); } public static MapSaveData LoadFromBytes(byte[] bytes) { return SerializationUtility.DeserializeValue(bytes, (DataFormat)1, (DeserializationContext)null); } public static void SaveTerrain() { } public static ObjectData BuildObjectData(Transform t) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown ObjectData objectData = new ObjectData { Id = GetIdFromGameObject(((Component)t).gameObject), Name = ((Object)((Component)t).gameObject).name, Transform = new TransformData { Position = t.localPosition, Rotation = t.localEulerAngles, Scale = t.localScale } }; Component[] components = ((Component)t).GetComponents(); Component[] array = components; foreach (Component val in array) { if (!((Object)(object)val == (Object)null) && !(val is Transform)) { if (val is PhotonView) { PhotonView val2 = (PhotonView)val; val2.ViewID = 0; val2.sceneViewId = 0; } objectData.Components.Add(SerializeComponent(val)); } } for (int j = 0; j < t.childCount; j++) { objectData.Children.Add(BuildObjectData(t.GetChild(j))); } return objectData; } private static ComponentData SerializeComponent(Component comp) { Type type = ((object)comp).GetType(); ComponentData componentData = new ComponentData { Type = type }; FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { if (!fieldInfo.IsStatic && !fieldInfo.IsNotSerialized && (fieldInfo.IsPublic || ((MemberInfo)fieldInfo).GetCustomAttribute() != null)) { object value = fieldInfo.GetValue(comp); componentData.Fields.Add(new FieldData { Name = fieldInfo.Name, Type = fieldInfo.FieldType, Value = value }); } } return componentData; } } } namespace TerrainCustomiser.Managers { internal static class BundleManager { internal static AssetBundle DebugShaderBundle; internal static AssetBundle VisibilityComputeBundle; internal static void Setup() { byte[] selectionoverlay = Resource1.selectionoverlay; DebugShaderBundle = AssetBundle.LoadFromMemory(selectionoverlay); GizmoUtils.SelectionOverlayShader = DebugShaderBundle.LoadAsset("SelectionOverlay.shader"); byte[] visibilitycompute = Resource1.visibilitycompute; VisibilityComputeBundle = AssetBundle.LoadFromMemory(visibilitycompute); LightMapBaker.computeShader = VisibilityComputeBundle.LoadAsset("SkyVisibilityDDA"); } internal static void UnloadAll() { DebugShaderBundle.Unload(true); VisibilityComputeBundle.Unload(true); } } internal static class ConfigManager { public static ConfigFile ConfigFile; public static ConfigEntry EnableLightMapBaking; public static ConfigEntry BakeLightMap; public static ConfigEntry UseRandomSeed; public static ConfigEntry SeedToUse; internal static void Setup() { ConfigFile = ((BaseUnityPlugin)Plugin.Instance).Config; ConfigFile.SaveOnConfigSet = true; EnableLightMapBaking = ConfigFile.Bind("General", "EnableLightMapBaking", true, "Generates a lightmap which is used for certain game mechanics. Disable this if the game crashes."); BakeLightMap = ConfigFile.Bind("UI", "BakeLightMap", false, "Stores the last set state of the Bake LightMap Checkbox in the Airport."); UseRandomSeed = ConfigFile.Bind("UI", "UseRandomSeed", true, "Stores the last set state of the Use Random Seed Checkbox in the Airport."); SeedToUse = ConfigFile.Bind("UI", "SeedToUse", 42, "Stores the last set state of the Set Seed Input Field in the Airport."); if (!EnableLightMapBaking.Value) { BakeLightMap.Value = false; } } } public class EditorManager : Singleton { public List levelGenStepTypes = new List { typeof(PropSpawner), typeof(PropSpawner_Line), typeof(PropSpawner_Sphere), typeof(PropDeleter) }; private MenuWindow menuWindow; public int currentSegmentIndex = 0; public MapData.BiomeSegment currentSegment; private EditorWindow editorWindow; public static InputAction action_pause; internal static void Setup() { SessionState.Set(SessionState.State.InEditor); ((Component)Plugin.Instance).gameObject.AddComponent(); } public GameObject CreateObject(string name, Transform parent, Vector3 position, Quaternion rotation) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_003a: 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) GameObject val = new GameObject(name); if ((Object)(object)parent == (Object)null) { parent = currentSegment.customVariant.transform; } val.transform.SetParent(parent); val.transform.position = position; val.transform.rotation = rotation; return val; } public GameObject CreateObjectWithComponent(string name, Transform parent, Type type, Vector3 position, Quaternion rotation) { //IL_0004: 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) GameObject val = CreateObject(name, parent, position, rotation); Component val2 = val.AddComponent(type); return val; } private void InitializeNullCollections(Component component) { FieldInfo[] fields = ((object)component).GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { Type fieldType = fieldInfo.FieldType; if (fieldInfo.GetValue(component) == null) { if (fieldType.IsArray) { Type elementType = fieldType.GetElementType(); Array value = Array.CreateInstance(elementType, 0); fieldInfo.SetValue(component, value); } else if (fieldType.IsGenericType && fieldType.GetGenericTypeDefinition() == typeof(List<>)) { object value2 = Activator.CreateInstance(fieldType); fieldInfo.SetValue(component, value2); } } } } public GameObject DuplicateObject(Transform target) { Transform val = Object.Instantiate(target); if ((Object)(object)target.parent != (Object)null) { val.SetParent(target.parent); } return ((Component)val).gameObject; } public void DestroyObject(GameObject go) { Object.Destroy((Object)(object)go); } private void SetupCamera() { CameraOverride val = ((Component)Camera.main).gameObject.AddComponent(); val.fov = Camera.main.fieldOfView; MainCamera component = ((Component)Camera.main).GetComponent(); if ((Object)(object)component != (Object)null) { ((Component)Camera.main).GetComponent().SetCameraOverride(val); GodCam godcam = Singleton.Instance.godcam; godcam.drag = 10f; godcam.force = 100f; godcam.lookDrag = 10f; godcam.lookSens = 100f; } } private void Update() { HandleInput(); TryDrawGizmos(); } private void TryDrawGizmos() { if (EditorGizmos.IsEnabled && (Object)(object)editorWindow.hierarchy.Selected != (Object)null) { LevelGenStep component = ((Component)editorWindow.hierarchy.Selected).gameObject.GetComponent(); GizmoUtils.TryDrawGizmos(editorWindow.hierarchy.Selected, (Component)(object)component); GizmoUtils.TryDrawOverlays(editorWindow.hierarchy.Selected); } } private void HandleInput() { if (UnityInput.Current.GetMouseButtonDown(1)) { SetGodCamActive(active: true); menuWindow.Hide(); } if (UnityInput.Current.GetMouseButtonUp(1)) { SetGodCamActive(active: false); menuWindow.Show(); } if (action_pause.WasPressedThisFrame()) { GUIManager.instance.pauseMenu.SetActive(!GUIManager.instance.pauseMenu.activeSelf); } } private void SetGodCamActive(bool active) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) Singleton.Instance.isGodCam = active; GodCam godcam = Singleton.Instance.godcam; if (!active) { godcam.lookVel = Vector2.zero; godcam.vel = Vector3.zero; godcam.targetFov = Singleton.Instance.currentFov; } } public void SetCurrentSegment(MapData.BiomeSegment biomeSegment) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) currentSegment = biomeSegment; MapSegment[] segments = Singleton.Instance.segments; foreach (MapSegment val in segments) { if ((Object)(object)val.segmentParent.transform == (Object)(object)biomeSegment.transform) { val.segmentParent.SetActive(true); if ((Object)(object)val.segmentCampfire != (Object)null) { val.segmentCampfire.SetActive(true); } ((Component)Camera.main).transform.position = ((Component)val.reconnectSpawnPos).transform.position + new Vector3(0f, 25f, 0f); if ((Object)(object)val.wallNext != (Object)null) { ((Component)Camera.main).transform.LookAt(val.wallNext.transform); } } else { val.segmentParent.SetActive(false); if ((Object)(object)val.segmentCampfire != (Object)null) { val.segmentCampfire.SetActive(false); } } } } public void GenerateCurrentSegment() { ((Component)currentSegment.transform).GetComponentInParent().RunAll(false); EditorGizmos.RefreshGizmos(); } public void ChangeBiome(MapData.BiomeSection biomeSection, MapData.BiomeOption targetBiome) { MapManager.ChangeBiome(biomeSection, targetBiome); SetCurrentSegment(targetBiome.segments.FirstOrDefault()); } protected override void Awake() { base.Awake(); } private void Start() { PrepareEditorMode(); } public override void OnDestroy() { base.OnDestroy(); WindowsManager.UnregisterAll(); } public void EndSession() { menuWindow.Close(); Object.Destroy((Object)(object)this); } public void LoadSave() { } private void PrepareEditorMode() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown action_pause = InputSystem.actions.FindAction("Pause", false); DisableFog(); DisableScoutmaster(); DisableCharacter(); DisableGameUI(); MapManager.DisableInactiveSegments(); ((Component)Singleton.Instance.globalParent).GetComponent().ClearAll(); GameObject val = new GameObject("MenuWindow"); val.transform.parent = ((Component)this).gameObject.transform; menuWindow = val.AddComponent(); WindowsManager.Register(); WindowsManager.Register(); WindowsManager.Register(); WindowsManager.Register(); if ((Object)(object)menuWindow != (Object)null) { menuWindow.Show(); } editorWindow = WindowsManager.Get(); HierarchyView hierarchy = editorWindow.hierarchy; hierarchy.OnSelectionChanged = (Action)Delegate.Combine(hierarchy.OnSelectionChanged, new Action(EditorGizmos.OnSelectionChanged)); } private void DisableFog() { GameObject val = GameObject.Find("Misc/Post Fog"); if ((Object)(object)val != (Object)null) { val.SetActive(false); } GameObject val2 = GameObject.Find("FogSphereSystem"); if ((Object)(object)val2 != (Object)null) { val2.SetActive(false); } } private void DisableScoutmaster() { Scoutmaster val = default(Scoutmaster); if (Scoutmaster.GetPrimaryScoutmaster(ref val)) { ((Component)val).gameObject.SetActive(false); } } private void DisableCharacter() { if ((Object)(object)Character.localCharacter != (Object)null) { ((Component)Character.localCharacter).gameObject.SetActive(false); Character.localCharacter = null; } } private void DisableGameUI() { if ((Object)(object)GUIManager.instance != (Object)null && (Object)(object)GUIManager.instance.hudCanvas != (Object)null) { ((Component)GUIManager.instance.hudCanvas).gameObject.SetActive(false); } if ((Object)(object)GamefeelHandler.instance != (Object)null) { PerlinShake componentInChildren = ((Component)GamefeelHandler.instance).gameObject.GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { ((Component)componentInChildren).gameObject.SetActive(false); } } } } internal static class NetworkManager { public static class PropertyKeys { public const string MapData = "mapData"; public const string PropViews = "propViews"; public const string PlayerInfo = "playerInfo"; public const string InCustomMap = "TC_inCustomMap"; } private static PhotonScopedManager _manager; private static SteamLobbyHandler _steamLobbyHandler; internal static void Setup() { _manager = PhotonCustomPropsUtilsPlugin.GetManager("com.snosz.terraincustomiser"); _steamLobbyHandler = GameHandler.GetService(); RegisterEvents(); } public static void SetRoomProperty(string propertyKey, object value) { _manager.SetRoomProperty(propertyKey, value); } public static void SetPlayerProperty(string propertyKey, object value) { _manager.SetPlayerProperty(propertyKey, value); } internal static void SetLobbyData(string propertyKey, string value) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (_steamLobbyHandler != null) { SteamMatchmaking.SetLobbyData(_steamLobbyHandler.LobbySteamId, propertyKey, value); } } internal static string GetLobbyData(string propertyKey) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (_steamLobbyHandler != null) { return SteamMatchmaking.GetLobbyData(_steamLobbyHandler.LobbySteamId, propertyKey); } return null; } private static void RegisterEvents() { _manager.RegisterRoomProperty("mapData", (RoomEventType)2, (Action)delegate(byte[] val) { OnMapDataChanged(val); }); _manager.RegisterRoomProperty("propViews", (RoomEventType)2, (Action)delegate(int[] val) { OnPropViewsChanged(val); }); _manager.RegisterOnJoinedRoom((Action)delegate { OnLocalPlayerJoinedRoom(); }); _manager.RegisterPlayerProperty("playerInfo", (PlayerEventType)1, (Action)delegate(Player targetPlayer, byte[] value) { OnPlayerInfoChanged(targetPlayer, value); }); } private static void OnMapDataChanged(byte[] val) { if (val == null) { PlayerInfoManager.currentMapSyncData = null; PlayerInfoManager.LocalPlayerInfo.hasMapData = false; } else { PlayerInfoManager.currentMapSyncData = NetworkUtils.DecompressMapSyncData(val); PlayerInfoManager.LocalPlayerInfo.hasMapData = true; if (SessionState.Is(SessionState.State.WaitingForMapData)) { SessionState.Set(SessionState.State.WaitingToStartCustomMap); MapHandler.InitializeMap(); } else { SessionState.Set(SessionState.State.WaitingToStartCustomMap); } } PlayerInfoManager.SendLocalPlayerInfo(); } private static void OnPropViewsChanged(int[] val) { if (!PhotonNetwork.IsMasterClient) { ViewSyncManager.ReceivePendingIds(val); } } private static void OnLocalPlayerJoinedRoom() { byte[] value = SerializationUtility.SerializeValue(PlayerInfoManager.LocalPlayerInfo, (DataFormat)1, (SerializationContext)null); SetPlayerProperty("playerInfo", value); } private static void OnPlayerInfoChanged(Player targetPlayer, byte[] val) { PlayerInfoManager.HandlePlayerInfoChanged(targetPlayer, val); if (PhotonNetwork.IsMasterClient && SessionState.Is(SessionState.State.WaitingToStartCustomMap) && PlayerInfoManager.LobbyHasMapData) { Plugin.Instance.LoadWilIsland(); } } } public class PlayerInfo { public bool canBake; public bool hasMapData; } internal static class PlayerInfoManager { public static Dictionary PlayersInfo = new Dictionary(); public static PlayerInfo LocalPlayerInfo; internal static MapSerializer.MapSyncData currentMapSyncData; public static bool LobbyCanBake = false; public static bool LobbyHasMapData = false; internal static void Setup() { LocalPlayerInfo = new PlayerInfo { canBake = ConfigManager.EnableLightMapBaking.Value }; } public static void HandlePlayerInfoChanged(Player targetPlayer, byte[] data) { PlayerInfo playerInfo = SerializationUtility.DeserializeValue(data, (DataFormat)1, (DeserializationContext)null); if (PlayersInfo.TryGetValue(targetPlayer, out PlayerInfo _)) { UpdatePlayerInfo(targetPlayer, playerInfo); } else { AddPlayerInfo(targetPlayer, playerInfo); } } public static void SendLocalPlayerInfo() { byte[] value = SerializationUtility.SerializeValue(LocalPlayerInfo, (DataFormat)1, (SerializationContext)null); NetworkManager.SetPlayerProperty("playerInfo", value); } public static void AddPlayerInfo(Player targetPlayer, PlayerInfo playerInfo) { PlayersInfo.Add(targetPlayer, playerInfo); if (PhotonNetwork.IsMasterClient) { LobbyCanBake = PlayersInfo.All>((KeyValuePair x) => x.Value.canBake); LobbyHasMapData = PlayersInfo.All>((KeyValuePair x) => x.Value.hasMapData); } } public static void RemovePlayerInfo(Player targetPlayer) { if (PlayersInfo.Remove(targetPlayer) && PhotonNetwork.IsMasterClient) { LobbyCanBake = PlayersInfo.All>((KeyValuePair x) => x.Value.canBake); LobbyHasMapData = PlayersInfo.All>((KeyValuePair x) => x.Value.hasMapData); } } public static void UpdatePlayerInfo(Player targetPlayer, PlayerInfo playerInfo) { PlayersInfo[targetPlayer] = playerInfo; if (PhotonNetwork.IsMasterClient) { LobbyCanBake = PlayersInfo.All>((KeyValuePair x) => x.Value.canBake); LobbyHasMapData = PlayersInfo.All>((KeyValuePair x) => x.Value.hasMapData); } } } internal static class ViewSyncManager { private static List pendingViews = new List(); private static int[] pendingIds; internal static void AddPendingView(PhotonView view) { if (!pendingViews.Contains(view)) { pendingViews.Add(view); } } internal static void ReceivePendingIds(int[] ids) { pendingIds = ids; HandlePendingViews(); } private static void ClearPending() { pendingViews.Clear(); pendingIds = null; } internal static void HandlePendingViews() { if (PhotonNetwork.IsMasterClient) { int[] value = AssignPendingViews(); NetworkManager.SetRoomProperty("propViews", value); ClearPending(); } else if (pendingIds != null && pendingIds.Length != 0) { ApplyPendingIds(); ClearPending(); } } private static int[] AssignPendingViews() { int[] array = new int[pendingViews.Count]; for (int i = 0; i < pendingViews.Count; i++) { int num = PhotonNetwork.AllocateViewID(false); pendingViews[i].ViewID = num; array[i] = num; } return array; } private static void ApplyPendingIds() { if (pendingIds.Length != pendingViews.Count) { Debug.LogError((object)$"[TC] ID Count mismatch! Map will be out of sync! Views: {pendingViews.Count}, Ids: {pendingIds.Length}."); return; } for (int i = 0; i < pendingIds.Length; i++) { if ((Object)(object)pendingViews[i] != (Object)null && (Object)(object)((Component)pendingViews[i]).gameObject != (Object)null) { pendingViews[i].ViewID = pendingIds[i]; } } } } public class WindowsManager : MonoBehaviour { private static WindowsManager _instance; private static List windows = new List(); internal static void Setup() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if (!((Object)(object)_instance != (Object)null)) { GameObject val = new GameObject("TC_WindowsManager"); ((Object)val).hideFlags = (HideFlags)61; _instance = val.AddComponent(); } } public static T Get() where T : ImGuiWindowBase { return (T)windows.Find((ImGuiWindowBase w) => w is T); } public static T Register() where T : ImGuiWindowBase, new() { T val = new T(); if (!windows.Contains(val)) { windows.Add(val); val.OnCreate(); } return val; } public static void Unregister() where T : ImGuiWindowBase { T val = (T)windows.Find((ImGuiWindowBase w) => w is T); if (val != null) { val.OnDestroy(); windows.Remove(val); } } public static void UnregisterAll() { foreach (ImGuiWindowBase window in windows) { window.OnDestroy(); } windows.Clear(); } private void OnEnable() { ImGui.Layout += OnLayout; } private void OnDisable() { ImGui.Layout -= OnLayout; } private void OnLayout() { DrawAll(); } private void DrawAll() { for (int i = 0; i < windows.Count; i++) { windows[i].DrawWindow(); } } } }