Decompiled source of TerrainCustomiser v0.3.2
TerrainCustomiser.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.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<GameObject> { 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<string, GameObject> keyValuePair = MapSerializer.GameObjectReferences.FirstOrDefault<KeyValuePair<string, GameObject>>((KeyValuePair<string, GameObject> 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<Material> { 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<Transform> { 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<string, GameObject> keyValuePair = MapSerializer.GameObjectReferences.FirstOrDefault<KeyValuePair<string, GameObject>>((KeyValuePair<string, GameObject> 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<EditorManager>.Instance); } public void LoadWilIsland() { AirportCheckInKiosk val = Object.FindFirstObjectByType<AirportCheckInKiosk>(); 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<Shape> _shapes = new List<Shape>(); 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<DebugVisualiser>(); } 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<Renderer> 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<Renderer> list = new List<Renderer>(); LODGroup[] componentsInChildren = target.GetComponentsInChildren<LODGroup>(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<Renderer>(true).ToList(); } public static List<RendererMaterialCache> ApplyOverlayToRenderers(List<Renderer> renderers) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown List<RendererMaterialCache> list = new List<RendererMaterialCache>(); 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<RendererMaterialCache> 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<RendererMaterialCache> list = new List<RendererMaterialCache>(); 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<RendererMaterialCache> 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<MapSerializer.MapSyncData>(@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<GizmoUtils.RendererMaterialCache> rendererMaterialCache = new List<GizmoUtils.RendererMaterialCache>(); 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<LevelGenStep>(); GizmoUtils.TryDrawGizmos(Target, (Component)(object)component); if ((Object)(object)component != (Object)null) { Renderer[] componentsInChildren = ((Component)Target).gameObject.GetComponentsInChildren<Renderer>(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<LevelGenStep>(); GizmoUtils.TryDrawGizmos(Target, (Component)(object)component); if ((Object)(object)component != (Object)null) { Renderer[] componentsInChildren = ((Component)Target).gameObject.GetComponentsInChildren<Renderer>(true); rendererMaterialCache = GizmoUtils.ApplyOverlayToRenderers(componentsInChildren); } } } } public class HierarchyView { public class ContextNode { public string Name; public List<ContextNode> Children = new List<ContextNode>(); public Action<Transform> Action; public Func<Transform, bool> CanUseNode; public void AddContextItem(string label, Action<Transform> action, Func<Transform, bool> canUseNode) { Children.Add(new ContextNode { Name = label, Action = action, CanUseNode = canUseNode }); } } public Action<Transform> OnSelectionChanged; public Func<Transform, bool> ShouldDrawNode; public List<ContextNode> ContextNodes = new List<ContextNode>(); 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<Transform, bool> canUseNode) { ContextNode contextNode = new ContextNode { Name = label, CanUseNode = canUseNode }; ContextNodes.Add(contextNode); return contextNode; } public void AddContextItem(string label, Action<Transform> action, Func<Transform, bool> 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<object> Get; public Action<object> Set; public RangeAttribute RangeAttribute = null; public bool IsHidden = false; public bool IsDisabled = false; public FieldWidgetData(Type type, Func<object> get, Action<object> 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<int> GetIndex; public Action<int> SetIndex; public Func<string[]> GetOptions; public ComboWidgetData(string name, Func<int> getIndex, Action<int> setIndex, Func<string[]> 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<string> spawnerHideFieldData = new List<string> { "_deferredSteps", "validationConstraints", "_propSpawnData", "_madeDummyData", "<ValidationState>k__BackingField", "<spawnedProps>k__BackingField" }; public static Dictionary<Type, FieldData[]> TypeFieldDataDictionary = new Dictionary<Type, FieldData[]>(); 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<object> get, Action<object> set, string id, RangeAttribute rangeAttribute = null) { Func<object> get2 = get; Action<object> 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<object> get, Action<object> 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<FieldWidgetData> list = new List<FieldWidgetData>(); 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<int> get, Action<int> set) { int obj = get(); if (ImGui.InputInt("##v", ref obj)) { set(obj); } } private static void DrawFloat(Func<float> get, Action<float> set) { float obj = get(); if (ImGui.InputFloat("##v", ref obj)) { set(obj); } } private static void DrawString(Func<string> get, Action<string> set) { string text = get(); if (text == null) { text = ""; } if (ImGui.InputText("##v", ref text, 32u)) { set(text); } } private static void DrawSliderFloat(Func<float> get, Action<float> set, float min, float max) { float obj = get(); if (ImGui.SliderFloat("##v", ref obj, min, max)) { set(obj); } } private static void DrawVector2(Func<Vector2> get, Action<Vector2> 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<Vector2Int> get, Action<Vector2Int> 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<Vector3> get, Action<Vector3> 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<Vector3Int> get, Action<Vector3Int> 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<Vector4> get, Action<Vector4> 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<Bounds> get, Action<Bounds> 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<bool> get, Action<bool> set) { bool obj = get(); if (ImGui.Checkbox("##v", ref obj)) { set(obj); } } private static void DrawEnum(Func<Enum> get, Action<Enum> 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<string[]> get, Action<int> set) { string[] array = get(); if (ImGui.Combo("##v", ref selectedIndex, array, array.Length)) { set(selectedIndex); } } private static void DrawColor(Func<Color> get, Action<Color> 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<GameObject> get, Action<GameObject> 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<GameObject>(get, set); WindowsManager.Get<ResourceWindow>().Open(); } } public static void DrawMaterial(Func<Material> get, Action<Material> 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<Material>(get, set); WindowsManager.Get<ResourceWindow>().Open(); } } private static void DrawTransform(Func<Transform> get, Action<Transform> 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<Transform>(get, set); WindowsManager.Get<ResourceWindow>().Open(); } } private static void DrawArray(Type elementType, Func<Array> get, Action<Array> 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<IList> 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<Array> 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<Array> 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<RangeAttribute>(); 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<RangeAttribute>(); 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<EditorManager>.Instance.SetCurrentSegment(MapData.biomeSections[0].activeBiome.segments[0]); SetupHierarchy(); } private void SetupHierarchy() { HierarchyView hierarchyView = hierarchy; hierarchyView.OnSelectionChanged = (Action<Transform>)Delegate.Combine(hierarchyView.OnSelectionChanged, (Action<Transform>)delegate(Transform t) { WindowsManager.Get<InspectorWindow>().SetTarget(t); }); hierarchy.ShouldDrawNode = (Transform t) => (Object)(object)((Component)t).GetComponent<LevelGenStep>() != (Object)null || (Object)(object)((Component)t).GetComponent<PropGrouper>() != (Object)null || (((Component)t).GetComponents<Component>().Length == 1 && (Object)(object)((Component)t.parent).GetComponent<PropGrouper>() != (Object)null); HierarchyView.ContextNode contextNode = hierarchy.AddContextMenu("Create Spawner", (Transform t) => (Object)(object)t == (Object)null || (Object)(object)((Component)t).GetComponent<LevelGenStep>() == (Object)null); foreach (Type item in Singleton<EditorManager>.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<EditorManager>.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<EditorManager>.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<LevelGenStep>() == (Object)null); hierarchy.AddContextItem("Duplicate", delegate(Transform t) { Singleton<EditorManager>.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<EditorManager>.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<EditorManager>.Instance.GenerateCurrentSegment); ImGui.SameLine(); ImGuiHelpers.DrawSmallButton("Save", SaveModal.Open); ImGui.SameLine(); ImGuiHelpers.DrawSmallButton("Load", LoadModal.Open); ImGui.SameLine(); ImGuiHelpers.DrawSmallButton("Cam", WindowsManager.Get<FreeCamWindow>().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<EditorManager>.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<MainCameraMovement>.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<Type> allowedTypes = new List<Type> { 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<EditorManager>.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>(); 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>(); 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<WidgetFactory.FieldData> enumerable = array2.Where((WidgetFactory.FieldData f) => f.layout == WidgetFactory.FieldLayout.Inline); IEnumerable<WidgetFactory.FieldData> enumerable2 = array2.Where((WidgetFactory.FieldData f) => f.layout == WidgetFactory.FieldLayout.Full); List<WidgetFactory.FieldWidgetData> list = new List<WidgetFactory.FieldWidgetData>(); 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<Object> _items = new List<Object>(); private static string filterBuffer = string.Empty; private static Func<Object> _get; private static Action<Object> _set; public override string WindowName => "Resources"; public override ImGuiWindowFlags WindowFlags => (ImGuiWindowFlags)64; public static void Show<T>(Func<T> get, Action<T> set) where T : Object { Func<T> get2 = get; Action<T> set2 = set; _get = () => (Object)(object)get2(); _set = delegate(Object o) { set2((T)(object)o); }; RebuildList<T>(); T val = get2(); _selectedIndex = (((Object)(object)val != (Object)null) ? _items.IndexOf((Object)(object)val) : (-1)); } private static void RebuildList<T>() 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<T>(); if (typeof(T) == typeof(GameObject)) { foreach (GameObject item in array.Cast<GameObject>()) { 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 : "<null>"); 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) { V